Skip to main content
 首页 » 编程设计

python之如何使用 pip 安装请求模块是否正确安装了 pip

2025年05月04日12leader

不知道pip是否安装正确。 我使用了 easy_install

它将 pip 脚本安装到: /Library/Frameworks/Python.framework/Versions/2.7/bin

但是,当我输入“pip”时,我会得到一个命令列表和一般选项 不是错误

但是当我尝试安装请求时,我得到:

Downloading/unpacking requests 
Cannot fetch index base URL (https://pypi.python.org/simple/). 
Could not find any downloads that satisfy the requirement requests 
 
$ python get-pip.py 
Downloading/unpacking pip 
Cannot fetch index base URL (https: //pypi.python. org/simple/). 
Could not find any downloads that satisfy the requirement pip 
Cleaning up... 
No distributions at all found for pip 
Storing debug log for failure in /Users/ariannaroyrp/.pip/pip.log 
 
 
$ sudo python get-pip.py 
 
WARNING: Improper use of the sudo command could lead to data loss 
or the deletion of important system files. Please double-check your 
typing when using sudo. Type "man sudo" for more information. 
 
To proceed, enter your password, or type Ctrl-C to abort. 
 
Password: 
Downloading/unpacking pip 
Cannot fetch index base URL https://pypi.python.org/simple/ 
Could not find any downloads that satisfy the requirement pip 
Cleaning up... 
No distributions at all found for pip 
Storing debug log for failure in /Users/ariannapryor/.pip/pip.log 
 
$ sudo python ez_install pip 
Password: 
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacO/Python: can't open file 'ez_install': [Errno 2] No such file or directory 
 
 
$ sudo python easy_install pip 
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacO/Python: can't open file 'easy_install': [Errno 2] No such file or directory 
 
$ easy_install pip 
Searching for pip 
Reading https: // pypi.python. org/simple/pip 
 
Best match: pip 1.5.5 
Downloading https: // pypi.python. org/packages/source/p/pip/pip-1.5.5.tar.gz#md5=7520581ba0687dec1ce85bd15496537b 
Processing pip-1.5.5.tar.gz 
Writing /var/folders/4x/15s0yxd96gd1lt_6xf1zt_x40000gn/T/easy_install-OwdJ8U/pip-1.5.5/setup.cfg 
Running pip-1.5.5/setup.py -q bdist_egg --dist-dir /var/folders/4x/15s0yxd96gd1lt_6xf1zt_x40000gn/T/easy_install-OwdJ8U/pip-1.5.5/egg-dist-tmp-xzS1S9 
warning: no files found matching 'pip/cacert.pem' 
warning: no files found matching '*.html' under directory 'docs' 
warning: no previously-included files matching '*.rst' found under directory 'docs/_build' 
no previously-included directories found matching 'docs/_build/_sources' 
Adding pip 1.5.5 to easy-install.pth file 
Installing pip script to /Library/Frameworks/Python.framework/Versions/2.7/bin 
Installing pip2.7 script to /Library/Frameworks/Python.framework/Versions/2.7/bin 
Installing pip2 script to /Library/Frameworks/Python.framework/Versions/2.7/bin 
 
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.5-py2.7.egg 
Processing dependencies for pip 
Finished processing dependencies for pip 
 
$ pip install requests 
Downloading/unpacking requests 
Cannot fetch index base URL https:// pypi.python. org/simple/ 
Could not find any downloads that satisfy the requirement requests 
Cleaning up... 
No distributions at all found for requests 
Storing debug log for failure in /Users/ariannaroyrp/.pip/pip.log 
 
$ pip 
 
Usage:    
  pip <command> [options] 
 
Commands: 
  install                     Install packages. 
  uninstall                   Uninstall packages. 
  freeze                      Output installed packages in requirements format. 
  list                        List installed packages. 
  show                        Show information about installed packages. 
  search                      Search PyPI for packages. 
  wheel                       Build wheels from your requirements. 
  zip                         DEPRECATED. Zip individual packages. 
  unzip                       DEPRECATED. Unzip individual packages. 
  bundle                      DEPRECATED. Create pybundles. 
  help                        Show help for commands. 
 
General Options: 
  -h, --help                  Show help. 
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times. 
  -V, --version               Show version and exit. 
  -q, --quiet                 Give less output. 
  --log-file <path>           Path to a verbose non-appending log, that only logs failures. This log 
                          is active by default at /Users/ariannapryor/.pip/pip.log. 
  --log <path>                Path to a verbose appending log. This log is inactive by default. 
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port. 
  --timeout <sec>             Set the socket timeout (default 15 seconds). 
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, 
                          (b)ackup. 
  --cert <path>               Path to alternate CA bundle. 
 
 
$ pip install requests 
Downloading/unpacking requests 
  Cannot fetch index base URL https:// pypi.python. org/simple/ 
  Could not find any downloads that satisfy the requirement requests 
Cleaning up... 
No distributions at all found for requests 
Storing debug log for failure in /Users/ariannaroyrp/.pip/pip.log 

有人可以向我解释一下这是怎么回事吗?

请您参考如下方法:

您的所有消息都报告了相同的问题:

Cannot fetch index base URL https:// pypi.python. org/simple/ 

注意 https:// 和 pypi...

之间的空格

看起来您在某处配置了 --index 并且它的值有误。

最好的办法是去掉所有影响配置的手段,以“干净”的方式运行

Configuration介绍以下方法

  • 配置文件
  • 环境变量

由于命令行开关优先,您可以尝试:

$ pip install requests --index "http://pypi.python.org/" 

但如果你成功了,你一定要研究一下,你在哪里搞砸了你的 pip 配置。