virtualenv: pip install virtualenv broken / missing zipp package

Thanks for submitting an issue!

If submitting a BUG please provide:

  • Minimal reproducible example or detailed descriptions
  • the output of the virtual environment creation with the -vvv --with-traceback flags included
  • pip list of the environment where virtualenv is installed into if not using the zipapp

I’ve created a minimal reproducible Dockerfile, it’s self explanatory:

FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
    python python-pip python-pkg-resources python-setuptools python-wheel python-dev libxslt1-dev
RUN pip install virtualenv --disable-pip-version-check --no-cache-dir


WORKDIR /root
RUN virtualenv venv

Full install log:

UN pip install virtualenv --disable-pip-version-check --no-cache-dir
 ---> Running in 92fa3d30b758
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/a3/dd/e43866ac0d25cd1ecbde0814f6cd7372ea257fbdf443dc9f0a01740da93d/virtualenv-20.0.4-py2.py3-none-any.whl (4.6MB)
Collecting six<2,>=1.9.0 (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Collecting distlib<1,>=0.3.0 (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/7d/29/694a3a4d7c0e1aef76092e9167fbe372e0f7da055f5dcf4e1313ec21d96a/distlib-0.3.0.zip (571kB)
Collecting importlib-metadata<2,>=0.12; python_version < "3.8" (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/8b/03/a00d504808808912751e64ccf414be53c29cad620e3de2421135fcae3025/importlib_metadata-1.5.0-py2.py3-none-any.whl
Collecting appdirs<2,>=1.4.3 (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Collecting importlib-resources<2,>=1.0; python_version < "3.7" (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/2f/f7/b4aa02cdd3ee7ebba375969d77c00826aa15c5db84247d23c89522dccbfa/importlib_resources-1.0.2-py2.py3-none-any.whl
Collecting filelock<4,>=3.0.0 (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/14/ec/6ee2168387ce0154632f856d5cc5592328e9cf93127c5c9aeca92c8c16cb/filelock-3.0.12.tar.gz
Collecting contextlib2<1,>=0.6.0; python_version < "3.3" (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/85/60/370352f7ef6aa96c52fb001831622f50f923c1d575427d021b8ab3311236/contextlib2-0.6.0.post1-py2.py3-none-any.whl
Collecting pathlib2<3,>=2.3.3; python_version < "3.4" and sys_platform != "win32" (from virtualenv)
  Downloading https://files.pythonhosted.org/packages/e9/45/9c82d3666af4ef9f221cbb954e1d77ddbb513faf552aea6df5f37f1a4859/pathlib2-2.3.5-py2.py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata<2,>=0.12; python_version < "3.8"->virtualenv)
  Downloading https://files.pythonhosted.org/packages/60/85/668bca4a9ef474ca634c993e768f12bd99af1f06bb90bb2655bc538a967e/zipp-2.2.0.tar.gz
  Running setup.py (path:/tmp/pip-build-pW7K_Y/zipp/setup.py) egg_info for package zipp produced metadata for project name unknown. Fix your #egg=zipp fragments.
Collecting configparser>=3.5; python_version < "3" (from importlib-metadata<2,>=0.12; python_version < "3.8"->virtualenv)
  Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Collecting typing; python_version < "3.5" (from importlib-resources<2,>=1.0; python_version < "3.7"->virtualenv)
  Downloading https://files.pythonhosted.org/packages/22/30/64ca29543375759dc589ade14a6cd36382abf2bec17d67de8481bc9814d7/typing-3.7.4.1-py2-none-any.whl
Collecting scandir; python_version < "3.5" (from pathlib2<3,>=2.3.3; python_version < "3.4" and sys_platform != "win32"->virtualenv)
  Downloading https://files.pythonhosted.org/packages/df/f5/9c052db7bd54d0cbf1bc0bb6554362bba1012d03e5888950a4f5c5dadc4e/scandir-1.10.0.tar.gz
Installing collected packages: six, distlib, contextlib2, unknown, scandir, pathlib2, configparser, importlib-metadata, appdirs, typing, importlib-resources, filelock, virtualenv
  Running setup.py install for distlib: started
    Running setup.py install for distlib: finished with status 'done'
  Running setup.py install for unknown: started
    Running setup.py install for unknown: finished with status 'done'
  Running setup.py install for scandir: started
    Running setup.py install for scandir: finished with status 'done'
  Running setup.py install for filelock: started
    Running setup.py install for filelock: finished with status 'done'
Successfully installed appdirs-1.4.3 configparser-4.0.2 contextlib2-0.6.0.post1 distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.5.0 importlib-resources-1.0.2 pathlib2-2.3.5 scandir-1.10.0 six-1.14.0 typing-3.7.4.1 unknown-0.0.0 virtualenv-20.0.4
Removing intermediate container 92fa3d30b758
 ---> 6127ebfdaa58
Step 5/6 : WORKDIR /root
 ---> Running in 3998fd059d5e
Removing intermediate container 3998fd059d5e
 ---> 62a1db87d19c
Step 6/6 : RUN virtualenv venv
 ---> Running in c40b1478666a
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 7, in <module>
    from virtualenv.__main__ import run_with_catch
  File "/usr/local/lib/python2.7/dist-packages/virtualenv/__init__.py", line 3, in <module>
    from .run import cli_run
  File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/__init__.py", line 9, in <module>
    from .plugin.activators import ActivationSelector
  File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/activators.py", line 6, in <module>
    from .base import ComponentBuilder
  File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/base.py", line 9, in <module>
    from importlib_metadata import entry_points
  File "/usr/local/lib/python2.7/dist-packages/importlib_metadata/__init__.py", line 9, in <module>
    import zipp
ImportError: No module named zipp
The command '/bin/sh -c virtualenv venv' returned a non-zero code: 1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

So I got some help on IRC, pip install -U pip fixed this issue.

Still, this would be great to either:

  • fixed or
  • terminate the installation with an error message if the system’s pip version is too old to support recent versions

this isn’t a bug in virtualenv, if you pip install zipp you’ll see the same issue

it’s a combination of two things:

  1. pip<9 will ignore python_requires selecting the latest version
  2. python2.x pip cannot utilize the py36-none-any wheel so it must build from source
  3. setuptools<30.3 cannot build declarative metadata packages from source

so you end up with:

  • a broken installation of python3.6+ zipp on python2.x named “unknown==0.0.0”

the easiest fix is to use a newer version of pip to install virtualenv, or to utilize the zipapp

Thinking this through I don’t think we can do anything here. If it’s already installed the only way we would know if our dependencies are correct is to manually check… and that’s very expensive.

setuptools 42.0.0 works though in this case 👍

You could even display that at runtime. It should simply display an error message when run on very old pip versions.