Pipenv --python 3.7.5 fails with exception

Asked by Matt Bayliss

Trying to use Pipenv to create a virtual environment in Ubuntu 19.04 and getting the following error, I've tried searching for a solution but I still don't really understand the problem.

Why does the follwing error occur as python-pip is installed on the system
ModuleNotFoundError: No module named 'pip._vendor.urllib3'

mattb@mattb-ubuntu1904:~/docs/code/pymail$ pipenv --python 3.7.5
Creating a virtualenv for this project…
Using /usr/bin/python3.7m (3.7.5) to create virtualenv…
⠋Running virtualenv with interpreter /usr/bin/python3.7m
Using base prefix '/usr'
/usr/lib/python3/dist-packages/virtualenv.py:1090: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
New python executable in /home/mattb/.local/share/virtualenvs/pymail-hNtF_hQh/bin/python3.7m
Also creating executable in /home/mattb/.local/share/virtualenvs/pymail-hNtF_hQh/bin/python
Installing setuptools, pkg_resources, pip, wheel...
  Complete output from command /home/mattb/.local/s...F_hQh/bin/python3.7m - setuptools pkg_resources pip wheel:
  Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
  File "/usr/share/python-wheels/pip-18.1-py2.py3-none-any.whl/pip/_internal/__init__.py", line 19, in <module>
ModuleNotFoundError: No module named 'pip._vendor.urllib3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 11, in <module>
ImportError: cannot import name 'main' from 'pip' (/usr/share/python-wheels/pip-18.1-py2.py3-none-any.whl/pip/__init__.py)
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 2379, in <module>
    main()
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main
    symlink=options.symlink)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 996, in create_environment
    download=download,
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 926, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/mattb/.local/s...F_hQh/bin/python3.7m - setuptools pkg_resources pip wheel failed with error code 1
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
ModuleNotFoundError: No module named 'apport'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 2379, in <module>
    main()
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main
    symlink=options.symlink)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 996, in create_environment
    download=download,
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 926, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/mattb/.local/s...F_hQh/bin/python3.7m - setuptools pkg_resources pip wheel failed with error code 1

Virtualenv location:
Creating a Pipfile for this project…

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Matt Bayliss
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of:

lsb_release -a; uname -a; python --version

Thanks

Revision history for this message
Matt Bayliss (aarrgghh765) said :
#2

Thanks for responding, ldb wasn't installed so I have now installed it but get the same error. Incidentally, I noticed that the hostname was incorrect so I have renamed it.

mattb@mattb-ubuntu1910:~/docs/code/pymail$ !lsb
lsb_release -a; uname -a; python --version
LSB Version: core-11.0.1ubuntu1-noarch:printing-11.0.1ubuntu1-noarch:security-11.0.1ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan
Linux mattb-ubuntu1910 5.3.0-26-generic #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Python 3.7.5

Revision history for this message
Matt Bayliss (aarrgghh765) said :
#3

I'm still not sure what the original problem was, but I proved that other users on the system could execute 'pipenv --python 3.7.5' without error so I ended up deleting the user account and re-creating it.