0

我正在尝试在我的 Mac 上为 TensorFlow 升级六个,我做到了:

sudo pip install --ignore-installed six

我得到:

The directory '/Users/lingxiao/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/lingxiao/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting six

/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/Library/Python/2.7/site-

packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.10.0

关键是它以成功安装结束。但是当我进入 ipython 解释器做:

import six
six.__version__

我仍然看到1.4.1。解决办法是什么?

4

1 回答 1

0

使用-U 或 --upgrade升级软件包:

sudo pip install --upgrade six

选项1:

在 ipython 中:

import pip

def install(package):
   pip.main(['install', package])

install('six')

选项 2:

在 ipython 中:

import sys
sys.path 

然后查看 ipython 的软件包安装在哪里。它应该看起来像:

'/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/six-1.4.1 blah blah'

在您的终端 python 中执行相同的操作,以查找安装较新的 6 包的位置。然后将较新的 6 包复制到 ipython 站点包目录中(先将 6-1.4.1 包移动到另一个目录以防万一)。

之后,将新包注册到 ipython 中:

# use your six located in your ipython path
six_path = '/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/six-1.10.0 blahblah'
sys.path.append(six_path) 

那么你也能

import six

ipython 应该在重启时跟踪更新的六个包。

于 2017-01-16T00:51:57.610 回答