我在IBM BlueMix上運行ipython筆記本,sklearn的默認版本是0.11版 - 我想升級到sklearn-0.18。BlueMix:無法將更新的sklearn導入iPython
編輯:我的意思是我想升級到sklearn-0.17。
import sklearn
print sklearn.__version__
0.11
的BlueMix文檔說使用:
!pip install -U --user sklearn
這裏是輸出:
You are using pip version 7.1.0, however version 8.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: sklearn in /gpfs/global_fs01/sym_shared/YPProdSpark/user/s3b2-519e0ce881616c-546ab68fb1ed/.local/lib/python2.7/site-packages
Collecting scikit-learn (from sklearn)
Using cached scikit-learn-0.17.tar.gz
Installing collected packages: scikit-learn
Running setup.py install for scikit-learn
Successfully installed scikit-learn-0.11
似乎並沒有工作。也許它與老版本的點有關...
!pip install --upgrade --user pip
You are using pip version 7.1.0, however version 8.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
Using cached pip-8.0.2-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-7.1.0
import pip
print pip.__version__
7.1.0
好的,所以它不只是sklearn。問題似乎是某種程度上升級的軟件包沒有安裝在正確的路徑中。
一些偵探後,我發現:
!ls -al ~/.local/lib/python2.7/site-packages
total 0
drwx------ 8 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 18:06 .
drwx------ 3 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 15:30 ..
drwxr-xr-x 10 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 15:46 pip
drwxr-xr-x 2 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 15:53 pip-8.0.1.dist-info
drwxr-xr-x 2 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 18:40 pip-8.0.2.dist-info
drwxr-xr-x 2 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 18:06 scikit_learn-0.17-py2.7.egg-info
drwxr-xr-x 25 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 18:06 sklearn
drwxr-xr-x 2 s3b2-519e0ce881616c-546ab68fb1ed users 4096 Jan 22 15:48 sklearn-0.0-py2.7.egg-info
那麼,讓我們試試這個...
import sys
sys.path.insert(0, '/gpfs/fs01/user/s3b2-519e0ce881616c-546ab68fb1ed/.local/lib/python2.7/site-packages/')
reload(sklearn)
print sklearn.__version__
0.17
現在,它看起來像的版本是正確的,所以嘗試導入一些新的函數sklearn-0.17。
from sklearn.metrics import roc_auc_score
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-169-8985e3efac9f> in <module>()
----> 1 from sklearn.metrics import roc_auc_score
ImportError: cannot import name roc_auc_score
我得到了與應該在版本0.17中的任何東西相同的錯誤。看起來python在嘗試導入時引用了舊的sklearn版本0.11。
任何幫助表示讚賞。
你有沒有考慮使用virtualenv? – 404pio
是......不情願。我寧願不去完成配置新環境的整個過程,但我想我可能需要爲此編寫一個腳本......因此,這可能是一個很好的練習。 – MichaelHood