我正在迈出学习 Python 的第一步,其中一部分就是在我的 MacBook Pro 上安装并运行它。我正在努力安装 pylint,因为 Visual Studio Code 不断通知我。
我被告知,进行 linter 操作是有益的,虽然我无法告诉你原因,但我决心从一开始就把事情做好。在编码方面我是一个十足的菜鸟。请保持友善。
我在 github 上找到了这个链接,尽管回复有 pip 超出我的范围:https://github.com/pypa/pip/issues/5465
附带问题 - pip 和 pip3 之间有区别吗?我的 bin 文件夹中似乎都有。谢谢:)
我尝试过的
我安装了 python 2.7(使用 mac 进行系统安装)和 python 3.7(hombrew 安装)。我已经更新了 pip(为此我必须使用“pip3 install --update pip”)
我尝试过: pip 安装 pylint pip3 安装 pylint sudo pip 安装 pylint
当我尝试 sudo 时(我后来读过它是不可取的),我还收到以下警告:
WARNING: The directory '/Users/maxwartelle/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/maxwartelle/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
这是安装的完整输出。我认为它正在使用缓存文件,因为我已经尝试过几次,第一次下载它们。
Maxs-MacBook-Pro:Exercise Files maxwartelle$ pip install pylint
Collecting pylint
Using cached https://files.pythonhosted.org/packages/60/c2/b3f73f4ac008bef6e75bca4992f3963b3f85942e0277237721ef1c151f0d/pylint-2.3.1-py3-none-any.whl
Collecting isort<5,>=4.2.5 (from pylint)
Using cached https://files.pythonhosted.org/packages/e5/b0/c121fd1fa3419ea9bfd55c7f9c4fedfec5143208d8c7ad3ce3db6c623c21/isort-4.3.21-py2.py3-none-any.whl
Collecting mccabe<0.7,>=0.6 (from pylint)
Using cached https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl
Collecting astroid<3,>=2.2.0 (from pylint)
Using cached https://files.pythonhosted.org/packages/d5/ad/7221a62a2dbce5c3b8c57fd18e1052c7331adc19b3f27f1561aa6e620db2/astroid-2.2.5-py3-none-any.whl
Collecting lazy-object-proxy (from astroid<3,>=2.2.0->pylint)
Using cached https://files.pythonhosted.org/packages/ad/57/a36f682668ffc453e86ddfb5a2a49848edcb7bd04a210a5a8692a48ed9c4/lazy-object-proxy-1.4.1.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Download error on https://pypi.org/simple/setuptools_scm/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076) -- Some packages may not be found!
Download error on https://pypi.org/simple/setuptools-scm/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076) -- Some packages may not be found!
Couldn't find index page for 'setuptools_scm' (maybe misspelled?)
Download error on https://pypi.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076) -- Some packages may not be found!
No local packages or working download links found for setuptools_scm>=3.3.1
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/_0/sncbcbsn5kd_03fhfjnr4czh0000gn/T/pip-install-mbw14gwe/lazy-object-proxy/setup.py", line 129, in <module>
for root, _, _ in os.walk('src')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/dist.py", line 717, in fetch_build_eggs
replace_conflicting=True,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1065, in best_match
return self.obtain(req, installer)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1077, in obtain
return installer(requirement)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/dist.py", line 784, in fetch_build_egg
return cmd.easy_install(req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools_scm>=3.3.1')
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_0/sncbcbsn5kd_03fhfjnr4czh0000gn/T/pip-install-mbw14gwe/lazy-object-proxy/
最佳答案
解决方案是运行“Install Certificates.command”shell 命令。
这可以在Applications\Python 3.7\中找到
就像我说的,完全菜鸟。
关于python - 如何安装 Pylint,克服错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56945117/