0

I have been trying to figure out what is causing this error, but every solution I've tried from totally uninstalling python and pip to rm-ing some folder doesn't work:

System Info: Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-88-generic x86_64)

python3 -V: Python 3.6.9

$ pip3 install -R requirements.txt 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.distro'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 67, in <module>
    vendored("distro")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 1051, in <module>
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 595, in __init__
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 932, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.

I tried to ensure pip:

python3.8 -m ensurepip
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.8/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/usr/lib/python3.8/ensurepip/__init__.py", line 200, in _main
    return _bootstrap(
  File "/usr/lib/python3.8/ensurepip/__init__.py", line 119, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/usr/lib/python3.8/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/__init__.py", line 40, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 8, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 7, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmp7_mor_ds/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/cmdoptions.py", line 15, in <module>
ModuleNotFoundError: No module named 'distutils'

And then tried to install distutils:

trever@server:~$ sudo apt install python3.8-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python3.8-lib2to3
The following NEW packages will be installed:
  python3.8-distutils python3.8-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 0 B/314 kB of archives.
After this operation, 1,235 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 194796 files and directories currently installed.)
Preparing to unpack .../python3.8-lib2to3_3.8.0-1+bionic2_all.deb ...
Unpacking python3.8-lib2to3 (3.8.0-1+bionic2) ...
dpkg: error processing archive /var/cache/apt/archives/python3.8-lib2to3_3.8.0-1+bionic2_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/lib2to3/Grammar.txt', which is also in package python3-lib2to3 3.6.9-1~18.04
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../python3.8-distutils_3.8.0-1+bionic2_all.deb ...
Unpacking python3.8-distutils (3.8.0-1+bionic2) ...
dpkg: error processing archive /var/cache/apt/archives/python3.8-distutils_3.8.0-1+bionic2_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/distutils/README', which is also in package python3-distutils 3.6.9-1~18.04
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3.8-lib2to3_3.8.0-1+bionic2_all.deb
 /var/cache/apt/archives/python3.8-distutils_3.8.0-1+bionic2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I can't even get it to remove / re-install it all:

trever@server:/usr/lib/python3.8$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python
Suggested packages:
  python-doc python-tk
The following NEW packages will be installed:
  python
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
7 not fully installed or removed.
Need to get 0 B/140 kB of archives.
After this operation, 639 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python2.7-minimal (2.7.17-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
/usr/bin/python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
 installed python2.7-minimal package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of python-minimal:
 python-minimal depends on python2.7-minimal (>= 2.7.15~rc1-1~); however:
  Package python2.7-minimal is not configured yet.

dpkg: error processing package python-minimal (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python2.7-minimal
 python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • You haven't provided your OS/release details, and then I'd look at what version of python3 you have setup as default (python3 -V) My guess is you're using something non-standard/modified outside of spec for your release/system. – guiverc Mar 5 at 7:35
  • I added that info, shows I have Python 3.6.9 – trever Mar 6 at 5:00
0

rm -rf /usr/lib/python3.7/site-packages

python3.7 -m ensurepip

pip install --upgrade pip

You need remove the pip package and not all the installed packages in site-packages

| improve this answer | |
  • When I try that I get /usr/bin/python3.7: No module named ensurepip – trever Mar 6 at 4:59
  • I edited my original post, I'm still not able to do this though. – trever Mar 6 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.