背景:在使用Github項目的時候耘斩,往往會遇到某個Python package對于版本的要求跟當前機器上的版本不符。通常的做法是通過pip install --upgrade XXX的方式來更新package就能夠解決版本問題,但某些情況下會出現(xiàn)一些無法卸載舊版本從而更新新版本的情況出現(xiàn)。
問題
$ pip install --upgrade XXX
Error: Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we
cannot accurately determine which files belong to it which would lead to only
a partial uninstall.
解決方案
1. Reduced version,
pip install --upgrade --force-reinstall pip==9.0.3
2. Tried to re-install package
pip install xxx --disable-pip-version-check
3. At last, recover the latest version for pip
pip install --upgrade pip