2017-01-16 93 views
0

我想在我的Mac TensorFlow升級六點,我所做的:無法在Mac OS X中的優勝美地升級6

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

您的'IPython'可能被設置爲使用與可執行'pip'不同的Python可執行文件。因此'pip'安裝一個Python版本,而'IPython'則運行另一個Python版本。看看你的'pip'腳本和'ipython'腳本的第一行,看看它們指向哪個Python可執行文件。 – Evert

+0

好的你是對的。在'python'中檢查pip .__ version__讓我獲得1.10.0和TensorFlow的預期功能。我如何確保iPython正在調用適當的六個版本?這個ipython腳本在哪裏? – chibro2

+0

你可以通過鍵入'which ipython'或'type ipython'找到'IPython'腳本。那麼它將取決於你是否想要使用IPython正在使用的Python可執行文件(因此,爲該Python安裝'six'),或者你想要改變'ipython'腳本的第一行。但是請注意,那麼可能找不到模塊,或者可能找不到IPython本身。 – Evert

回答

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中應重啓保持較新的6包的軌道。

+0

沒有,並且仍然有6個1.4.1在我的Python – chibro2

+0

@ chibro2完成添加選項。 – ooknosi

+0

這些都是圍繞實際問題的竅門;它不會解決未來的問題。如果'ipython'碰巧是一個Python 3腳本,那麼路徑設置就會失敗。 – Evert

相關問題