mac vscode配置python环境
时间: 2023-08-26 20:15:02 浏览: 352
对于在Mac上配置Python环境,您可以按照以下步骤操作:
1. 安装Homebrew(如果您已经安装了,请跳过此步骤):打开终端,运行以下命令安装Homebrew:
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
2. 安装Python3:在终端中运行以下命令来使用Homebrew安装Python3:
```bash
brew install python@3.9
```
3. 配置默认Python版本:运行以下命令将刚刚安装的Python3设置为默认版本:
```bash
echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```
如果您使用的是Bash终端,请将上述命令中的`.zshrc`替换为`.bashrc`或`.bash_profile`。
4. 安装Visual Studio Code:您可以从Visual Studio Code官方网站(https://code.visualstudio.com/)下载并安装Visual Studio Code。
5. 打开Visual Studio Code并安装Python插件:在Visual Studio Code中,点击左侧侧边栏中的扩展图标(或按下`Ctrl+Shift+X`),搜索并安装"Python"插件。
6. 配置Python解释器:在Visual Studio Code中,按下`Ctrl+Shift+P`打开命令面板,然后输入"Python: Select Interpreter"并选择您安装的Python解释器(通常是`python3`)。
至此,您已经成功配置了Python环境,并可以使用Visual Studio Code进行Python开发了!如果您想要安装其他Python包,可以使用`pip`命令进行安装。
阅读全文
相关推荐


















