【问题标题】:How to install requests module with pip? Is pip properly installed?如何使用 pip 安装 requests 模块? pip 是否正确安装?
【发布时间】:2014-05-13 20:30:44
【问题描述】:

不知道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

谁能给我解释一下这里发生了什么?

【问题讨论】:

  • 在终端中执行ping pypi.python.org。你得到了什么?
  • 我实际上最终安装了旧版本的 pip (1.2.1),它一直在工作

标签: python macos python-2.7 pip


【解决方案1】:

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

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

注意https://pypi... 之间的空格

您似乎在某处配置了 --index,但它的值有误。

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

Configuration 描述以下方法

  • 配置文件
  • 环境变量

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

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

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

【讨论】:

  • 谢谢!我最终使用旧版本的 pip 让它工作,因为 1.5.5 显然存在 SSL 证书问题。我最终使用了“sudo easy_install pip==1.2.1”
猜你喜欢
  • 2020-09-16
  • 2017-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-31
  • 2017-03-28
  • 1970-01-01
相关资源
最近更新 更多