I'm attempting to install python3.6 on my machine after I currently have python3.4. However, after installation trying to run pip
under python3.6 gives me the error:
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", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
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'
There were several comments on the internet about that error being encountered, However, none of them contain any actual resolution suggestion. Does anyone have any idea how I could fix this?
I managed to solve it without installing anything from sources. Here's what I did:
First, install
pip
for Python3.x (for some weird reason I didn't have it...)It is an old version...
... so upgrade it to the latest
Now it is much better
Then upgrade
virtualenvvwrapper
Now creating a new virtualenv works:
pip
also works:Note: Now I realize it's a bit more than what you asked for, but (without knowing where exactly you failed) I guess you should be OK after step 2.
I was having the same issue. It seems I had 2 versions of
pkg_resources
on my system./usr/local/lib/python3.6/site-packages/pkg_resources.py
/usr/lib/python3.6/site-packages/pkg_resources/__init__.py
Moving the old version so my system could find the newer version fixed it for me.
mv /usr/local/lib/python3.6/site-packages/pkg_resources.py /usr/local/lib/python3.6/site-packages/pkg_resources.py.back
You can solve this error by using this command. it will update your setuptools
I replaced Python 3.4 with 3.6 on my Ubuntu 14.04 servers and I had the same problem. In my case the cause seemed to be an ancient system pip:
I have never installed python3-pip. Instead I solved the error as follows:
I could not solve it by running
or
because there I already had issues with pkg_resources.py. Also re-installing the python3-setuptools package from Ubuntu did not help as this still seems to install the one for the version originally installed with the Ubuntu system (3.4 in my case) but I could solve it by manually installing the setuptools via
Note: python3 points to my new python version 3.6. If thats not the case for you then you would need to run
Had the same problem. Installing python from the source helped.
Edit: I since discovered pyenv. Makes installing and managing different python versions a lot easier. Give it a try!