简体   繁体   English

在 VSCode 上安装 Pylint 时权限被拒绝

[英]Permission denied when installing Pylint on VSCode

When trying to enable linting with Pylint, and format on save with autopep8, neither will install because of a permission denied error.当尝试使用 Pylint 启用 linting 并使用 autopep8 进行格式保存时,由于权限被拒绝错误,两者都不会安装。

Pylint:派林特:

IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/mccabe.py'

Autopep8: Autopep8:

IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pep8.py'

You can press ⬆ (up arrow key) in the terminal tab after the install fails to return to the command that it ran.安装失败后,您可以在终端选项卡中按 ⬆(向上箭头键),返回到它运行的命令。 In this case:在这种情况下:

/usr/bin/python -m pip install pylint

Press fn+⬅ (left arrow key) to jump to the beginning of the line, then insert a 'sudo ' (no quotes, but including the trailing space) in front of the command, and press enter to re-run the command as root -- it should look like this:按 fn+⬅(向左箭头键)跳转到行首,然后在命令前面插入一个 'sudo'(没有引号,但包括尾随空格),然后按 Enter 以 root 身份重新运行该命令-- 它应该是这样的:

sudo /usr/bin/python -m pip install pylint

You will be prompted for your password then the package will be installed without permissions errors.系统将提示您输入密码,然后安装软件包时不会出现权限错误。

运行此命令:

sudo chown -R $USER /Library/Python/2.7

Use for Python V3+用于 Python V3+

sudo -H python -m pip install pylint

then simply check the version via然后只需通过检查版本

pylint --version 

should output something like应该输出类似的东西

pylint 2.6.2
astroid 2.4.2
Python 3.9.1 (default, Feb  1 2021, 12:12:57) 
[Clang 12.0.0 (clang-1200.0.32.29)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM