Python virtualenv error on Arch Linux

After installing the latest Arch Linux Updates the Python virtualenv tool stops with an error.

Since many years I use the virtualenv tool to create virtual environments for my Python development and testing. But after the last Arch Linux Update it fails and prints an error message. You can find an example in the listing below.

$ virtualenv --python=/usr/bin/python3 venv
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3259, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3242, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3271, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 584, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'distlib<1,>=0.3.0' distribution was not found and is required by virtualenv

It looks like the package is missing a dependency to the package python-distlib. After installing the package everything works like before.

$ sudo pacman -S python-distlib

If you don't want to install the package you can also use the venv module included in Python since Version 3.3.

python3 -m venv venv

Links

Verwandte Artikel