iro*_*and 12 python visual-studio-code
要对 Python 使用 linting,我配置VS Code
如下:
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": true,
"python.linting.lintOnTextChange": true,
"python.linting.lintOnSave": true
Run Code Online (Sandbox Code Playgroud)
然后我打开一个*.py
文件并添加了一个不必要的空间并保存,然后我得到一个错误:Linter pep8 is not installed
.
但我已经安装了pep8
. 通过使用 VS Code 控制台,我可以找到pep8
.
/usr/bin/python -m pip install pep8
loading ~/.zshrc_osx
ironsand@macbook ~ % /usr/bin/python -m pip install pep8
/usr/bin/python: No module named pip
ironsand@macbook ~ % which python
/usr/bin/python
ironsand@macbook ~ % which pep8
/usr/local/bin/pep8
ironsand@macbook ~ % pep8 --version
1.7.0
ironsand@macbook ~ % which python
/usr/bin/python
ironsand@macbook ~ %
Run Code Online (Sandbox Code Playgroud)
也许我pep8
通过使用pip2
安装了安装brew
。
python --version
Python 2.7.10
ironsand@macbook ~ % /usr/local/bin/pip2 install pep8
Collecting pep8
Using cached pep8-1.7.0-py2.py3-none-any.whl
Installing collected packages: pep8
Successfully installed pep8-1.7.0
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
MagicPython 1.0.12
Python 0.7.0
Python for VSCode 0.2.3
Run Code Online (Sandbox Code Playgroud)
Mil*_*enk 15
PEP8 被重命名为pycodestyle。在 Python VS Code 扩展(由 Microsoft)中,它已在命令面板和 settings.json 文件中重命名。然而,它们的文档还不是最新的,它们可能会令人困惑。
pep8的问题是因为vscode现在用的是flake8,基本一样,pep8改名为pycodestyle,flake8用的是pycodestyle,这是旧配置:
"python.linting.pep8Enabled": true, // Don't use it
Run Code Online (Sandbox Code Playgroud)
但是现在你在 vscode 中找不到那个配置,现在新的配置行是:
"python.linting.flake8Enabled": true, // This is the new config for pep8
Run Code Online (Sandbox Code Playgroud)
如果第二个选项不起作用,您可以尝试以下操作:
"python.linting.pycodestyleEnabled": true // You need: pip install pycodestyle
Run Code Online (Sandbox Code Playgroud)
我希望这个答案对你有帮助
听起来可能微不足道,但是你安装了Python
vscode 吗?DonJayamanne 的那一款效果很好。
如果是这样,请尝试将你的pythonPath添加到你的 vscode 编辑器中settings
,至少,它解决了我的问题。
pep8
路径应该是自动发现的,如果没有,您可能还想添加您的pep8Path。
归档时间: |
|
查看次数: |
14508 次 |
最近记录: |