Python 使用pip安装django 1.7.1版时出错

Python 使用pip安装django 1.7.1版时出错,python,django,installation,pip,django-1.7,Python,Django,Installation,Pip,Django 1.7,通过pip install django==1.7.1 Downloading/unpacking django==1.7.1­­ Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded Installing collected packages: django Cleaning up... Exception: Traceback (most recent call last): File "/Libr

通过
pip install django==1.7.1

Downloading/unpacking django==1.7.1­­
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 279, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 1380, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 664, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 894, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 202, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 189, in clobber
    os.makedirs(destsubdir)
  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'

Storing debug log for failure in /Users/hansonzihanzeng/Library/Logs/pip.log
你应该写

sudo pip install django==1.7.1

您遇到了一个
权限被拒绝的
错误,这意味着进程无法写入目录,因为它没有足够的权限

您必须使用sudo来允许写入权限

sudopip安装django==1.7.1

Downloading/unpacking django==1.7.1­­
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 279, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 1380, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 664, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 894, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 202, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 189, in clobber
    os.makedirs(destsubdir)
  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'

Storing debug log for failure in /Users/hansonzihanzeng/Library/Logs/pip.log
但是,如果您想在Python3(3.x)上安装它,您必须使用pip3

sudopip3安装django==1.7.1

Downloading/unpacking django==1.7.1­­
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 279, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 1380, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 664, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/pip/req.py", line 894, in move_wheel_files
    pycompile=self.pycompile,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 202, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 189, in clobber
    os.makedirs(destsubdir)
  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'

Storing debug log for failure in /Users/hansonzihanzeng/Library/Logs/pip.log
但是,如果您在终端中为自己提供根权限,则不必使用sudo。 您可以使用
sudo su
命令并输入密码来获得root用户。完成后,在该窗口中执行的任何操作都将被视为具有root权限。然而,这通常不是好的做法