-bash:pylint:找不到命令

时间:2017-04-12 14:02:26

标签: macos python-2.7 terminal pip pylint

我一直在尝试安装要在终端上使用的pylint,但是在使用它时却没有成功。安装成功,但每当我尝试运行pylint命令时,它都会返回以下错误 -

-bash: pylint: command not found

我尝试过使用以下命令 -

pip install pylint
python -m pip install pylint
sudo pip install pylint
sudo -H pip install pylint

我已经卸载它,在尝试上述每个命令之前,但每次安装它时,安装都会成功,但是我无法在命令行上使用它。我知道这是我想念的傻事。

这是我安装的输出 -

My-Mac:Dev noob$ sudo -H pip install pylint
Collecting pylint
  Using cached pylint-1.6.5-py2.py3-none-any.whl
Requirement already satisfied: isort>=4.2.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: mccabe in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: configparser; python_version == "2.7" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: backports.functools-lru-cache; python_version == "2.7" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: astroid<1.5.0,>=1.4.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from pylint)
Requirement already satisfied: wrapt in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from astroid<1.5.0,>=1.4.5->pylint)
Requirement already satisfied: lazy-object-proxy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from astroid<1.5.0,>=1.4.5->pylint)
Installing collected packages: pylint
Successfully installed pylint-1.6.5

PS:我在2011年末Macbook pro上使用macOS Sierra 10.12.3,如果这是相关的。

2 个答案:

答案 0 :(得分:3)

问题是已安装的python可执行文件未添加到您的路径中。我们的路径看起来并不完全相同(可能是因为我不确定不同的python版本),但是我的路径是

host:~ williamhammond$ pip install pylint
Requirement already satisfied: pylint in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (2.3.1)
Requirement already satisfied: astroid<3,>=2.2.0 in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from pylint) (2.2.5)
Requirement already satisfied: isort<5,>=4.2.5 in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from pylint) (4.3.21)
Requirement already satisfied: mccabe<0.7,>=0.6 in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from pylint) (0.6.1)
Requirement already satisfied: wrapt in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from astroid<3,>=2.2.0->pylint) (1.11.2)
Requirement already satisfied: six in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from astroid<3,>=2.2.0->pylint) (1.12.0)
Requirement already satisfied: typed-ast>=1.3.0; implementation_name == "cpython" in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from astroid<3,>=2.2.0->pylint) (1.4.0)
Requirement already satisfied: lazy-object-proxy in /Users/williamhammond/Library/Python/3.7/lib/python/site-packages (from astroid<3,>=2.2.0->pylint) (1.4.1)

直到我看着这里

,我都遇到了与您相同的问题
host:~ williamhammond$ ls /Users/williamhammond/Library/Python/3.7/bin/
dmypy           epylint         isort           mypy            pep8            pylint          pyreverse       stubgen         symilar

将其添加到

之类的路径后
export PATH=$PATH:/Users/williamhammond/Library/Python/3.7/bin/

您应该可以使用pylint。要使此更改永久生效,请确保将命令添加到您的~/.bashrc

答案 1 :(得分:-1)

您必须将pylint添加到PATH环境变量中。 首先检查pylint的安装位置

whereis pylint

然后将返回路径添加到PATH env变量

export PATH=$PATH:/path/returned/by/whereis