当我尝试安装 virtualenv 时,是什么导致了这个错误?IOError: [Errno 13] 权限被拒绝: '/Library/Python/2.7/site-packages/virtualenv.py'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24504231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:42:12  来源:igfitidea点击:

What's causing this error when I try and install virtualenv? IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

pythonflaskvirtualenv

提问by Takeshi Patterson

I'm trying to install a virtual environment using the command:

我正在尝试使用以下命令安装虚拟环境:

pip install virtualenv

pip install virtualenv

but I get the following error:

但我收到以下错误:

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

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

How do I fix this?

我该如何解决?

采纳答案by idiot.py

At a glance it looks like you need admin permissions to install packages on your system. Try starting pip as admin or your OS equivalent.

乍一看,您似乎需要管理员权限才能在系统上安装软件包。尝试以管理员或您的操作系统等效身份启动 pip。

回答by Luckie Hao

Your account does not have write access to this directory?.

您的帐户没有此目录的写权限?。

  1. If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account.

    sudo pip install virtualenv
    
  2. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHON_PATHenvironment variable.

  3. easier way: change that dir permission:

    chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages
    
  1. 如果安装目录是系统拥有的目录,您可能需要以管理员或“root”帐户登录。

    sudo pip install virtualenv
    
  2. 如果您没有对这台机器的管理访问权限,您可能希望选择不同的安装目录,最好是在您的PYTHON_PATH环境变量中列出的目录。

  3. 更简单的方法:更改该目录权限:

    chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages
    

回答by TeeTracker

You don't have permission to edit the system-wide version of this library. Try using sudo:

您无权编辑此库的系统范围版本。尝试使用sudo

sudo pip install --upgrade virtualenv