简体   繁体   English

在 Mac OS X 上安装 pip 时出错

[英]errors installing pip on Mac OS X

I'm trying to install pip on a Mac OS X system using python version 2.6 and got the following errors.我正在尝试使用 python 2.6 版在 Mac OS X 系统上安装 pip 并收到以下错误。

$ python /tmp/get-pip.py 
/tmp/tmpzyN3Si/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Collecting pip
/tmp/tmpzyN3Si/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Exception:
Traceback (most recent call last):
  File "/tmp/tmpLZAZtY/pip.zip/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/tmp/tmpLZAZtY/pip.zip/pip/commands/install.py", line 280, in run
    requirement_set.prepare_files(finder)
  File "/tmp/tmpLZAZtY/pip.zip/pip/req/req_set.py", line 317, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/tmp/tmpLZAZtY/pip.zip/pip/req/req_set.py", line 304, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/tmp/tmpLZAZtY/pip.zip/pip/req/req_set.py", line 439, in _prepare_file
    req_to_install.populate_link(finder, self.upgrade)
  File "/tmp/tmpLZAZtY/pip.zip/pip/req/req_install.py", line 244, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/tmp/tmpLZAZtY/pip.zip/pip/index.py", line 486, in find_requirement
    all_versions = self._find_all_versions(req.name)
  File "/tmp/tmpLZAZtY/pip.zip/pip/index.py", line 404, in _find_all_versions
    index_locations = self._get_index_urls_locations(project_name)
  File "/tmp/tmpLZAZtY/pip.zip/pip/index.py", line 378, in _get_index_urls_locations
    page = self._get_page(main_index_url)
  File "/tmp/tmpLZAZtY/pip.zip/pip/index.py", line 810, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/tmp/tmpLZAZtY/pip.zip/pip/index.py", line 920, in get_page
    "Cache-Control": "max-age=600",
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/requests/sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "/tmp/tmpLZAZtY/pip.zip/pip/download.py", line 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 36, in send
    cached_response = self.controller.cached_request(request)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/cachecontrol/controller.py", line 102, in cached_request
    resp = self.serializer.loads(request, self.cache.get(cache_url))
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/cachecontrol/serialize.py", line 108, in loads
    return getattr(self, "_loads_v{0}".format(ver))(request, data)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/cachecontrol/serialize.py", line 184, in _loads_v2
    return self.prepare_response(request, cached)
  File "/tmp/tmpLZAZtY/pip.zip/pip/_vendor/cachecontrol/serialize.py", line 145, in prepare_response
    **cached["response"]
TypeError: __init__() keywords must be strings

Then I tried it with python2.6:然后我用python2.6试了一下:

python2.6 /tmp/get-pip.py
/tmp/tmpI57ALq/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
/tmp/tmpI57ALq/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB)
    100% |################################| 1.1MB 303kB/s 
Collecting setuptools
  Downloading setuptools-18.3.1-py2.py3-none-any.whl (462kB)
    100% |################################| 462kB 723kB/s 
Collecting wheel
  Downloading wheel-0.24.0-py2.py3-none-any.whl (63kB)
    100% |################################| 65kB 3.6MB/s 
Collecting argparse (from wheel)
  Downloading argparse-1.3.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, argparse, wheel
Successfully installed argparse-1.3.0 pip-7.1.2 setuptools-18.3.1 wheel-0.24.0

But pip command can't be found when I try to use it.但是当我尝试使用它时找不到 pip 命令。

$  which pip
pip not found

When I run python2.6 again, I get the following:当我再次运行 python2.6 时,我得到以下信息:

python2.6 /tmp/get-pip.py
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/tmp/tmpCu8MaZ/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Requirement already up-to-date: pip in /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

I've read that pip install requests[security] would solve the problem but first I need to install pip in order to install those packages.我读过pip install requests[security]可以解决这个问题,但首先我需要安装 pip 才能安装这些包。

EDIT : It seems like this is a bug related to the Python 2.6.1.编辑:这似乎是与 Python 2.6.1 相关的错误。 I have installed a newer version of Python (2.7.10) with Homebrew and installed pip using easy_install.我已经使用 Homebrew 安装了更新版本的 Python (2.7.10) 并使用 easy_install 安装了 pip。 Then I added path /usr/local/bin to have a priority and pip installs packages now.然后我添加了路径 /usr/local/bin 以获得优先级,现在 pip 安装包。 I'm not sure if it's ok to use non-native python for pip though.不过,我不确定将非本地 python 用于 pip 是否可以。

Did you try easy_install ?你试过easy_install吗?

Here's an EASY solution.这是一个简单的解决方案。

First of all, make sure you have Python installed.首先,确保你已经安装了Python How?如何? Open terminal and run the following command.打开终端并运行以下命令。

python --version

If this command returns a version number that means python is already installed.如果此命令返回一个版本号,则表示已经安装了 python。 That also means you already have access to easy_install considering you are using OS X .这也意味着考虑到您使用的是OS X您已经可以访问easy_install

Now, all you have to do is run the following command.现在,您所要做的就是运行以下命令。

sudo easy_install pip

After that, pip will be installed and you'll be able to use it for installing other packages.之后, pip将被安装,您将能够使用它来安装其他软件包。

Cheers!干杯! Let me know if this way of installing pip worked for you.让我知道这种安装 pip 的方式是否适合您。 💯 💯

Re Install Python And then it will work .重新安装 Python 然后它就可以工作了。 Pip comes pre-installed when you install Python on your system .当您在系统上安装 Python 时,会预先安装 Pip。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM