问题描述
我正在终端中使用 pip 安装 django 。
I'm trying to install django using pip in Terminal.
我总是得到一个例外,然而。最后一个错误总是被拒绝,我不明白为什么。任何帮助不胜感激。
I always get an exception, however. The last error is always "permission denied", and I do not understand why. Any help is appreciated.
日志:
pip install django
You are using pip version 7.1.0, however version 8.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting django
Using cached Django-1.9.4-py2.py3-none-any.whl
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 646, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 310, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 70, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'
推荐答案
我的解决方案[Errno 13]权限被拒绝:
My Solution for [Errno 13] Permission denied:
目标:将软件包安装到system / virtualenv中
Target: To install package into system/virtualenv
为什么你会遇到这个问题?
因为除了root,你创建的其他用户没有写入站点包的权限,这就是为什么你得到该用户拒绝操作系统错误的权限
Why you get this problem? Because apart from root, other users you created don't have permission to write to site-packages, that is why you get OS error permission denied for that user
如何解决?
确保您始终激活了virtualenv
源bin / activate
假设我创建了一个用户
(sampleEnv)sunny @ ubuntu-512mb-lon1-01:pip install django
这将给出权限错误,而不是转移到根
This will give the Permission error, Instead of that shift to root
(sampleEnv)root @ ubuntu-512mb-lon1-01:pip install django
现在root有权写入站点包。
Now root have permission to write to site-packages.
一旦安装了django。转回用户
Once django is installed. Shift back to user
然后做点冻结你可以看到系统中安装的软件包,然后继续!
then do pip freeze you can see packages installed in system and go on!
这篇关于pip安装django错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!