首页 > 解决方案 > 如何解决 Python Pylint 安装错误

问题描述

我尝试使用以下命令在我的 VS Code 中安装Pylint :

pip install pylint

输出是这样的:

Requirement already satisfied: pylint in c:\users\domin\appdata\roaming\python\python39\site-packages (2.6.0)
Requirement already satisfied: toml>=0.7.1 in c:\users\domin\appdata\roaming\python\python39\site-packages (from pylint) (0.10.1)
Requirement already satisfied: astroid<=2.5,>=2.4.0 in c:\users\domin\appdata\roaming\python\python39\site-packages (from pylint) (2.4.2)
Requirement already satisfied: isort<6,>=4.2.5 in c:\users\domin\appdata\roaming\python\python39\site-packages (from pylint) (5.6.1)
Requirement already satisfied: colorama in c:\users\domin\appdata\roaming\python\python39\site-packages (from pylint) (0.4.3)
Requirement already satisfied: mccabe<0.7,>=0.6 in c:\users\domin\appdata\roaming\python\python39\site-packages (from pylint) (0.6.1)
Requirement already satisfied: six~=1.12 in c:\users\domin\appdata\roaming\python\python39\site-packages (from astroid<=2.5,>=2.4.0->pylint) (1.15.0)
Requirement already satisfied: wrapt~=1.11 in c:\users\domin\appdata\roaming\python\python39\site-packages (from astroid<=2.5,>=2.4.0->pylint) (1.12.1)
Requirement already satisfied: lazy-object-proxy==1.4.* in c:\users\domin\appdata\roaming\python\python39\site-packages (from astroid<=2.5,>=2.4.0->pylint) (1.4.3)

它只返回简单的光标:

PS C:\Users\domin> 

每当我尝试使用它时,VS Code 都会返回以下消息:

pylint : The term 'pylint' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pylint .
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (pylint:String) [], CommandNotFo 
   undException
    + FullyQualifiedErrorId : CommandNotFoundException

我应该怎么办?

标签: pythonpython-3.xinstallationpippylint

解决方案


这个输出告诉你,你已经得到了这个包,它的依赖项安装在 python 3.9 的站点包中。

如果你需要在你的机器上安装特定的 python 版本来安装它,你需要输入以下内容:

/path/to/your/bin/python -m pip install pylint

与 virtualenv 相同。如果要将其安装到 virtualenv python 中:

source mypython/bin/activate
pip install pylint

推荐阅读