Some more info:

Inserting a 'print(cmd)' at line 259 showed that the direct cause of
the error message is the command:

  ['/home/flo/python-venv/testdir/bin/python3.5',
   '-Im', 'ensurepip', '--upgrade', '--default-pip']

exiting with a non-zero exit status. Running this command by hand after
the venv creation failed yields:

~/python-venv % /home/flo/python-venv/testdir/bin/python3.5 -Im ensurepip 
--upgrade --default-pip; echo $?
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.5/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/usr/lib/python3.5/ensurepip/__init__.py", line 218, in _main
    version="pip {}".format(version()),
  File "/usr/lib/python3.5/ensurepip/__init__.py", line 74, in version
    assert len(wheel_names) == 1, wheel_names
AssertionError: []
1
~/python-venv %

The assertion error comes from this in
/usr/lib/python3.5/ensurepip/__init__.py:

    wheel_names = glob.glob('/usr/share/python-wheels/pip-*.whl')
    assert len(wheel_names) == 1, wheel_names

and indeed:

~/python-venv % ls /usr/share/python-wheels/pip-*.whl
zsh: no matches found: /usr/share/python-wheels/pip-*.whl
~/python-venv % apt-file search /usr/share/python-wheels/pip-
virtualenv: /usr/share/python-wheels/pip-8.0.2-py2.py3-none-any.whl
~/python-venv %

I then installed the 'virtualenv' package, which does provide the
mentioned file, and tried to recreate the venv from scratch after adding
a 'print(os.getcwd())' right after the previously-added 'print(cmd)' in
/usr/lib/python3.5/venv/__init__.py (lines 259-260, before the 'try'
statement in EnvBuilder._setup_pip()):

~/python-venv % rm -rf testdir
~/python-venv % /usr/bin/python3.5 -m venv testdir
['/home/flo/python-venv/testdir/bin/python3.5', '-Im', 'ensurepip', 
'--upgrade', '--default-pip']
/home/flo/python-venv
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

~/python-venv % /usr/bin/python3.5 -c "import subprocess; 
subprocess.check_output(['/home/flo/python-venv/testdir/bin/python3.5', '-Im', 
'ensurepip', '--upgrade', '--default-pip'])"
Traceback (most recent call last):
  File 
"/tmp/tmpicb907db/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/__init__.py", line 
33, in vendored
ImportError: No module named 'pip._vendor.cachecontrol'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.5/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/usr/lib/python3.5/ensurepip/__init__.py", line 269, in _main
    default_pip=args.default_pip,
  File "/usr/lib/python3.5/ensurepip/__init__.py", line 175, in bootstrap
    _run_pip(args + _PROJECTS, additional_paths)
  File "/usr/lib/python3.5/ensurepip/__init__.py", line 65, in _run_pip
    import pip
  File "/tmp/tmpicb907db/pip-8.0.2-py2.py3-none-any.whl/pip/__init__.py", line 
12, in <module>
  File "/tmp/tmpicb907db/pip-8.0.2-py2.py3-none-any.whl/pip/exceptions.py", 
line 6, in <module>
  File 
"/tmp/tmpicb907db/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/__init__.py", line 
52, in <module>
  File 
"/tmp/tmpicb907db/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/__init__.py", line 
35, in vendored
ImportError: No module named 'cachecontrol'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 
'['/home/flo/python-venv/testdir/bin/python3.5', '-Im', 'ensurepip', 
'--upgrade', '--default-pip']' returned non-zero exit status 1
~/python-venv %

-- 
Florent

Reply via email to