[英]How to stop autopep8 not installed messages in Code
I'm a new Python programmer using the Mac version of VS Code 1.45.1 to create a Django project.我是一个新的 Python 程序员,使用 Mac 版本的 VS Code 1.45.1 创建一个 Django 项目。 I have the Python and Django extensions installed.
我安装了 Python 和 Django 扩展。 Every time I save a Django file, Code pops up this window:
每次我保存一个Django的文件,代码弹出这个window:
Formatter autopep8 is not installed. Install?
Source: Python (Extension) [Yes] [Use black] [Use yapf]
I keep clicking the "Yes" button to install the autopep8 extension but this message keeps popping up nevertheless.我一直单击“是”按钮来安装 autopep8 扩展,但此消息仍然不断弹出。 Is there some trick to configuring VS Code so that this extension will be installed permanently and I stop getting this error?
配置 VS Code 是否有一些技巧,以便永久安装此扩展并且我不再收到此错误?
You will receive this prompt if您将收到此提示,如果
"formatOnSave"
turned on as a setting"formatOnSave"
作为设置打开 So the options are:所以选项是:
My guess is there's an installation failure because you are using a globally installed interpreter and you're not allowed to install where pip wants to put autopep8.我的猜测是安装失败,因为您使用的是全局安装的解释器,并且不允许安装 pip 想要放置 autopep8 的位置。
pip install pep8
pip install --upgrade autopep8
or或者
"python.formatting.provider": "autopep8"
I have also encountered this problem in my computer with Ubuntu 18.04.我在我的电脑上也遇到了这个问题,Ubuntu 18.04。 It turns out that the python extension need some settings.
事实证明,python 扩展需要一些设置。 My solution is:
我的解决方案是:
Adding this in for anyone who has this issue running WSL on Windows .为在 Windows 上运行 WSL 时遇到此问题的任何人添加此内容。 You need to either need to be connected to Remote WSL in order to access pep8 in your WSL Python installation or install Python and pep8 on Windows since VS Code will be looking on Windows.
You need to either need to be connected to Remote WSL in order to access pep8 in your WSL Python installation or install Python and pep8 on Windows since VS Code will be looking on Windows. No matter how magnificently installed
autopep8
may be in WSL, VS Code won't find it.无论在 WSL 中安装
autopep8
多么出色,VS Code 都找不到它。
So my full solution was:所以我的完整解决方案是:
autopep8
in your Windows Python instance.autopep8
。 eg, from Command Prompt: python3 -m pip install autopep8
The easiest way to work with autopep8 in VSCode to follow the steps:在 VSCode 中使用 autopep8 的最简单方法是遵循以下步骤:
pip install autopep8
into the desired virtual envpip install autopep8
将 autopep8 安装到所需的虚拟环境中ctrl +,
which will open the settingsctrl +,
这将打开设置formatter
formatter
Python-autopep8
in Editor: Default Formatter
Python-autopep8
Editor: Default Formatter
程序Editor: Format On Save
if he/she wishes toEditor: Format On Save
Install autopep from your terminal by running the following command通过运行以下命令从终端安装 autopep
python -m pip install autopep8
That should solve the error 2 in vscode of no such file or directory error那应该可以解决vscode中没有此类文件或目录错误的错误2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.