我正试图在我的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。解决方案是什么?
答案 0 :(得分:0)
使用-U or --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中做同样的事情,找到你安装新的六个包的位置。然后将新的六个包复制到ipython site-packages目录中(以防万一)将six-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应该在重启时跟踪新的六个包。