【问题标题】:What is the error I am facing when I am installing Django via PIP in a virtualenv?当我通过 PIP 在 vi​​rtualenv 中安装 Django 时遇到什么错误?
【发布时间】:2015-03-26 12:16:36
【问题描述】:

在我的 OSX 10.10.2 上,在 virtualenv 中,我尝试使用以下命令通过 pip 安装 Django:

pip install django

这是我得到的回应:

Collecting django
  Downloading Django-1.7.7-py2.py3-none-any.whl (7.4MB)
    100% |################################| 7.4MB 58kB/s 
Installing collected packages: django

  Exception:
  Traceback (most recent call last):
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/commands/install.py", line 347, in run
      root=options.root_path,
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_set.py", line 549, in install
      **kwargs
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 754, in install
      self.move_wheel_files(self.source_dir, root=root)
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/req/req_install.py", line 963, in move_wheel_files
      isolated=self.isolated,
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 266, in move_wheel_files
      clobber(source, dest, False, fixer=fixer, filter=filter)
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/site-packages/pip/wheel.py", line 212, in clobber
      shutil.copyfile(srcfile, destfile)
    File "/Users/qmbp/.virtualenvs/demo/lib/python3.4/shutil.py", line 109, in copyfile
      with open(dst, 'wb') as fdst:
  PermissionError: [Errno 13] Permission denied: '/Users/qmbp/.virtualenvs/demo/bin/django-admin.py'

我猜这个问题是因为我没有在命令前加上 sudo。但我读到在 OSX 中使用 sudo 是个好主意。这就是为什么鼓励使用 virtualenv,因为其中不需要 sudo。

这是我的文件的屏幕截图,因为我在 bin 文件夹中找不到“env”。

【问题讨论】:

    标签: python django pip


    【解决方案1】:

    你好像忘记激活你的venv了。

    试试:

    source path_to_your_venv/bin/activate
    pip install django
    

    【讨论】:

    • 抱歉,这是一个简单的问题。如何找到venv的路径?仅供参考,我已经在 venv 中,我在运行 pip install 之前做了 的工作
    • 在我的 path_to_your_venv/bin/ 中,没有任何名为 env 的东西
    猜你喜欢
    • 2016-05-27
    • 1970-01-01
    • 1970-01-01
    • 2014-04-09
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    • 2015-10-08
    • 2013-08-21
    相关资源
    最近更新 更多