我目前有python3.4后,我正试图在我的机器上安装python3.6。但是,安装后试图在python3.6下运行pip给我错误:
Traceback (most recent call last): File "pip3",line 7,in <module> from pip import main File "/usr/lib/python3/dist-packages/pip/__init__.py",line 59,in <module> from pip.log import logger File "/usr/lib/python3/dist-packages/pip/log.py",line 9,in <module> import colorama,pkg_resources File "/usr/lib/python3/dist-packages/pkg_resources.py",line 1520,in <module> register_loader_type(importlib_bootstrap.SourceFileLoader,DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py",line 63,in apport_excepthook from apport.fileutils import likely_packaged,get_recent_crashes File "/usr/lib/python3/dist-packages/apport/__init__.py",line 5,in <module> from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py",line 30,in <module> import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py",line 23,in <module> from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py",line 20,in <module> import apt File "/usr/lib/python3/dist-packages/apt/__init__.py",in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Original exception was: Traceback (most recent call last): File "pip3",DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
我设法解决了它,没有从源头安装任何东西。
这是我做的:
原文链接:https://www.f2er.com/ubuntu/349211.html这是我做的:
>首先,为Python3.x安装pip(出于一些奇怪的原因,我没有它…)
$ sudo apt-get install python3-pip
这是旧版本……
$ pip3 --version pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)
> …所以升级到最新版本
$ sudo pip3 install --upgrade pip
现在好多了
$ sudo pip3 --version pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
>然后升级virtualenvvwrapper
$ sudo pip3 install --upgrade virtualenvwrapper # ... Successfully installed pbr-3.0.1 six-1.10.0 stevedore-1.22.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2
>现在创建一个新的virtualenv工作:
$ mkvirtualenv -p `which python3.6` <VIRTUALENV_NAME>
点子也有效:
$ pip install django # ... Successfully installed django-1.11.2 pytz-2017.2 $ pip freeze Django==1.11.2 pytz==2017.2
注意:现在我意识到它比你要求的要多一点,但是(不知道你到底在哪里失败了)我猜你应该在第2步之后做好。