OSError:[Errno 13]权限被拒绝:'/ usr / local / lib / python2.7 / site -packages / Django'

时间:2017-08-28 08:46:28

标签: python django

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/local/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/django'

如何安装Django?!?!?!

4 个答案:

答案 0 :(得分:1)

通过以下方式安装:

sudo pip install django或者像@ Y0da建议的那样。

答案 1 :(得分:0)

您没有权限,因此请使用以下方式在本地安装:

pip install django --user

这会将其安装在.local中,您必须附加变量PYTHONPATH

答案 2 :(得分:0)

您可能忘记激活/安装python虚拟环境。同样的问题已解决here

答案 3 :(得分:0)

激活virtualenv(source env / bin / activate)并尝试重新安装。