在 VS Code 上的 conda venv 中安装 pip3 和 flake8

Install pip3 and flake8 in conda venv on VS Code

目标:让 flake8 linting 工作

我设置了一个新的 conda venv。我尝试 select Flake8 作为我在 Command Palette 中的 linter。

更新:我已经安装了 pipflake8。但是VS Code提示:

Ubuntu Bash 终端机:

(sdg) me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (20.0.2-5ubuntu1.6).
0 upgraded, 0 newly installed, 0 to remove and 124 not upgraded.

(sdg) me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/foo/bar$ pip install flake8
Requirement already satisfied: flake8 in /home/me/.local/lib/python3.8/site-packages (4.0.1)
Requirement already satisfied: pyflakes<2.5.0,>=2.4.0 in /home/me/.local/lib/python3.8/site-packages (from flake8) (2.4.0)
Requirement already satisfied: pycodestyle<2.9.0,>=2.8.0 in /home/me/.local/lib/python3.8/site-packages (from flake8) (2.8.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /home/me/.local/lib/python3.8/site-packages (from flake8) (0.6.1)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the '/home/me/miniconda3/envs/sdg/bin/python -m pip install --upgrade pip' command.

.vscode/settings.json:

{
    "python.linting.flake8Enabled": true,
    "python.linting.enabled": true
}

我一直在关注这些解决方案,但没有成功

Install Pip

Use Flake8

建议您适当创建conda环境:

conda create -n "myenv" python

然后,激活环境:

conda activate myenv

最后,安装 flake:

pip install flake8