权限被拒绝 pip virtualenv [英] permission denied pip virtualenv

查看:21
本文介绍了权限被拒绝 pip virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试设置 virtualenv 以与 django 一起使用,但我一直在使用 pip 安装 virtualenv 时遇到问题.

I have been trying to set up virtualenv for use with django, but I keep having issues installing virtualenv with pip.

jeff@jeff-HP-MacBook-Android:~/repos$ pip install virtualenv
Collecting virtualenv
  Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/virtualenv.py'
jeff@jeff-HP-MacBook-Android:~/repos$ 

我能找到的最接近的答案是关于 virtualenv 中的权限:如何避免权限被拒绝"使用 pip 和 virtualenv 时

The closest answer I can find regards permissions inside the virtualenv: How to avoid "Permission denied" when using pip with virtualenv

但据我所知,我的问题是我的 pip 安装有问题,因为我显然还没有 virtualenv.

But from what I can tell my issue is that there's something wrong with my install of pip, since I apparently don't even have virtualenv yet.

推荐答案

我认为您的 pip 安装没有任何问题.virtualenv 本身是一个 Python 模块,默认情况下它位于/usr/local/lib/python2.7/dist-packages 中,您的用户没有写入权限的文件夹.如果您有 sudo 访问权限,最简单的方法是尝试:

I don't think there's anything wrong with your pip installation. virtualenv is itself a Python module, and by default it goes in /usr/local/lib/python2.7/dist-packages, a folder for which your user does not have write permissions. If you have sudo access, it would be easiest to simply try:

sudo pip install virtualenv

一旦你这样做了,你应该能够在不需要使用 sudo 的情况下创建 virtualenv.或者,此处有制作您自己的虚拟环境的说明,但看起来您可能需要对其指导您下载的脚本进行一些手动编辑.

Once you've done that, you should be able to create virtualenvs without needing to use sudo. Alternately, there are instructions here for making your own virtual environment, but it looks like you will likely need to do some manual editing of the script it directs you to download.

这篇关于权限被拒绝 pip virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆