简体   繁体   English

Errno 13运行virtualenv时权限被拒绝

[英]Errno 13 Permission denied when running virtualenv

When trying to create a virtualenv using a brew-installed Python 2.7 on Mac OS XI get the following error: 在Mac OS XI上尝试使用brew安装的Python 2.7创建virtualenv时会出现以下错误:

Could not install packages due to an EnvironmentError: 
  [Errno 13] Permission denied: '/lib'

Full output: 全输出:

▶ virtualenv ./virtualenv               
New python executable in /Users/alexharvey/git/home/sam-test/virtualenv/bin/python2.7
Also creating executable in /Users/alexharvey/git/home/sam-test/virtualenv/bin/python
Installing setuptools, pip, wheel...                    

  Complete output from command /Users/alexharvey/gi...ualenv/bin/python2.7 - setuptools pip wheel:
  Looking in links: /usr/local/lib/python2.7/site-packages, /usr/local/lib/python2.7/site-packages/virtualenv_support, /usr/local/lib/python2.7/site-packages/virtualen
v_support                                                                                                                                                             
Collecting setuptools                                                       
  Using cached https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl      
Collecting pip                                                          
Collecting wheel                                                                                                                                                      
  Using cached https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl           
Installing collected packages: setuptools, pip, wheel                                                                                                                 
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/lib'
Consider using the `--user` option or check the permissions.                                                                                                          

----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 11, in <module>
    sys.exit(main())                                                                                                                                                  
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 762, in main                                                                                      
    symlink=options.symlink,
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 1015, in create_environment
    install_wheel(to_install, py_executable, search_dirs, download=download)
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 968, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)                                                                                              
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 854, in call_subprocess
    raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))
OSError: Command /Users/alexharvey/gi...ualenv/bin/python2.7 - setuptools pip wheel failed with error code 1

I see that questions like this have been asked here frequently before (eg here ) and yet upvoted answers seem to recommend using sudo , which is obviously wrong. 我看到这样的问题在此之前经常被问到(例如这里 ),但是upvoted答案似乎建议使用sudo ,这显然是错误的。

Note I have followed recommendations at this page here: Using python effectively on Mac OS X . 注意我已按照此页面上的建议操作: 在Mac OS X上有效地使用python

How can I fix this (without using sudo)? 我该如何解决这个问题(不使用sudo)?

As suggested in a comment, there was an issue with a custom Distutils config file. 正如评论中所建议的那样,自定义Distutils配置文件存在问题。 This file can apparently be in one of three places ( ref ): 这个文件显然可以在三个地方之一( 参考 ):

  • system : <prefix>/lib/pythonver/distutils/distutils.cfg system<prefix>/lib/pythonver/distutils/distutils.cfg
  • personal : $HOME/.pydistutils.cfg 个人$HOME/.pydistutils.cfg
  • local : setup.cfg localsetup.cfg

I had meanwhile created a setup.cfg according to this SO answer here with content: 我同时创建一个setup.cfg根据本SO回答这里的内容:

[install]
prefix=

I can no longer remember why I had consulted that answer, or why I had put that file there, but after I removed it, virtualenv worked fine again, and I'm not having any more issues. 我不能再记得为什么我咨询了这个答案,或者为什么我把那个文件放在那里,但是在我删除它之后,virtualenv再次正常工作,我没有任何问题。

Installing anything into global /lib obviously requires root privileges. 在global /lib安装任何东西显然需要root权限。

You can install modules to your user's folder without using sudo , just add --user argument when installing any package. 您可以在不使用sudo的情况下将模块安装到用户的文件夹,只需在安装任何软件包时添加--user参数即可。

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

相关问题 Errno 13在WSL,virtualenv中(甚至以root用户身份)被拒绝的权限 - Errno 13 Permission denied, in WSL, virtualenv, even as root 错误 13 权限被拒绝 - Errno 13 Permission Denied 错误 13 权限被拒绝: - Errno 13 Permission denied: Errno 13许可被拒绝:? - Errno 13 Permission denied:? Errno 13 更新 conda 时权限被拒绝 - Errno 13 Permission denied when updating conda Python-运行cron作业时出现“ IOError:[Errno 13]权限被拒绝”,但从命令行运行时却没有 - Python - “IOError: [Errno 13] Permission denied” when running cron job but not when running from command line Errno 13 权限被拒绝:当脚本在后端运行时尝试访问 CSV 文件时 - Errno 13 Permission denied: when trying to access the CSV file when script is running in backend IOError: [Errno 13] 权限被拒绝: &#39;geckodriver.log 在运行 Python/Selenium 时 - IOError: [Errno 13] Permission denied: 'geckodriver.log when running Python/Selenium PermissionError: [errno 13] 在 Windows 10 中运行 python 脚本时权限被拒绝 - PermissionError: [errno 13] permission denied when running python script in Windows 10 IOError:Errno 13权限在Powershell中运行python循环时拒绝D:/ PDF - IOError: Errno 13 Permission Denied D:/PDFs when running python loop in Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM