1. 程式人生 > >解決 ImportError: cannot import name '__version__'

解決 ImportError: cannot import name '__version__'

使用brew升級python後,報了command not found: pip3的錯誤,並且使用pip時會出現另外一個錯誤:

Traceback (most recent call last):
File “/usr/local/bin/pip”, line 7, in
from pip._internal import main
File “/usr/local/lib/python3.6/site-packages/pip/_internal/init.py”, line 41, in
from pip import version
ImportError: cannot import name ‘version

解決辦法:

wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

此時pip2能夠成功執行
但是pip3仍然會報command not found: pip3的錯誤

wget https://pypi.python.org/packages/41/80/268fda78a53c2629128f8174d2952c7f902c93ebaa2062b64f27aa101b07/setuptools-38.2.3.zip#md5=0ae64455d276ff864b40aca9c06ea7c1
unzip setuptools-38.2
.3.zip cd setuptools-38.2.3 python setup.py install wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9 tar xf pip-9.0.1.tar.gz cd pip-9.0.1 python setup.py install ln -s ../**n/pip3 /usr/local/bin/pip3

此時能夠成功執行pip3

命令