您好我在使用pip尝试安装Django时在我的Mac上出现此错误。我创建了一个目录和虚拟环境。但是在尝试安装django时遇到了这个错误。
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/req/req_set.py", line 731, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/req/req_install.py", line 841, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/req/req_install.py", line 1040, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/wheel.py", line 343, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/wheel.py", line 314, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg/pip/utils/__init__.py", line 82, 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'
答案 0 :(得分:2)
您是否已激活虚拟环境?
source env/bin/activate
看起来您正在运行默认点,并且您无权安装到目录中。如果您运行sudo pip install django
,它应该有效。