python 安装 pip

1.下载 pip

https://bootstrap.pypa.io/get-pip.py
可以把上述地址内容拷贝至任意 xxx.py 文件中

2.运行文件

然后在xxx.py的目录下终端执行:

python pip.py

如果报错:
localhost:20171213 let$ python pip.py 
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 780kB/s 
Collecting wheel
  Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
    100% |████████████████████████████████| 51kB 3.3MB/s 
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/var/folders/n7/zm4kvng53553j0vxzc15brr80000gn/T/tmprD65si/pip.zip/pip/utils/__init__.py", line 83, 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/pip-9.0.1.dist-info'
解决报错

sudo python pip.py

然后查看版本:

pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)

你可能感兴趣的:(python 安装 pip)