当我尝试使用 pip 在 Windows 上安装 pylint 时,我遇到了这个问题,我真的不知道它来自哪里。
C:Python33Scripts>pip.exe install pylint
Downloading/unpacking pylint
Getting page https://pypi.python.org/simple/pylint/
URLs to search for versions for pylint:
* https://pypi.python.org/simple/pylint/
Analyzing links from page https://pypi.python.org/simple/pylint/
...
byte-compiling C:Python33Libsite-packagespylintutils.py to utils.cpython-33.pyc
byte-compiling C:Python33Libsite-packagespylint__init__.py to __init__.cpython-33.pyc
byte-compiling C:Python33Libsite-packagespylint__pkginfo__.py to __pkginfo__.cpython-33.pyc
error: The system cannot find the file specified
running 2to3 on C:Python33Libsite-packagespylinttest
----------------------------------------
Cleaning up...
Removing temporary dir c:windowstemppip_build_abrow198...
Command C:Python33python.exe -c "import setuptools;__file__='c:\windows\temp\pip_build_abrow198\pylint\setup.py';exec(compile(open(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record c:windowstemppip-cq0pam-recordinstall-record.txt --single-version-externally-managed failed with error code 1 in c:windowstemppip_build_abrow198pylint
看起来 Pylint 及其依赖项 logilab-common 的设置脚本中都存在错误。使用pip install pylint
或python setup.py install
构建时遇到错误。
错误通常如下所示,并在.pyc
文件进行字节编译后立即发生:
error: The system cannot find the file specified
running 2to3 on C:Python33Libsite-packagespylinttest
仅仅确保2to3.py
在 PATH 上可用似乎是不够的;2to3 本身可以运行,但 Pylint 不会安装。
我只是花了一点时间试图让它工作,并发现了两个有希望的建议:
第一个选项,创建自定义 bat 文件,以便 2to3 有效地在您的 PATH 上(请参阅 SO 线程,问题跟踪器)。我设法让2to3
在PowerShell和CMD中作为裸命令运行,但无法安装Pylint。其他人可能会对此有更多的运气。
第二种选择,安装不同版本的 Pylint 和 logilab-common,它们通过 distutils 而不是在命令行上调用 2to3(参见未合并的拉取请求)。这立即对我有用。
BitBucket 自 10 月以来将该拉取请求列为"开放"。我不知道它何时会被合并,或者该更改可能会在 PyPI 上存活多久。