gpt4 book ai didi

python - 操作系统错误 : [Errno 13] Permission denied when installing django

转载 作者:太空宇宙 更新时间:2023-11-03 13:16:32 24 4
gpt4 key购买 nike

我在新安装的 ubuntu 14.04 上,我已经安装了 pip 和虚拟环境,但是当我尝试安装 django 时,我收到以下错误消息:

name@computername:/$ pip install django
Collecting django
Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django

Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 549, in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 740, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 949, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 234, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/django'

它确实有效,但是当我尝试在 venv 上安装时有效。

这与 $PYTHONPATH 有什么关系吗?

(我相信当我尝试在一个已经启动的项目上运行 runserver 时,这也会导致冲突。但如果这个问题不能解决,我会把它留给另一个问题。)

最佳答案

您需要activate首先是您的虚拟环境。

$ source PATH_TO_ENV/bin/env
$ pip install django

In a newly created virtualenv there will also be a activate shell script. For Windows systems, activation scripts are provided for the Command Prompt and Powershell.

On Posix systems, this resides in /ENV/bin/

除非你这样做,否则你正在使用系统 python 和系统库。这就是您看到错误的原因。

如果您需要将库安装到系统范围内,您需要 root 访问权限:

$ sudo pip install django

关于python - 操作系统错误 : [Errno 13] Permission denied when installing django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28306440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com