Tuesday, January 30, 2024

[SOLVED] virtualenv creation fails with error "StopIteration"

Issue

In attempt to slim down a Docker image with a large Python environment, I tried removing as many files and directories as possible (cached packages, __pycache__ directories, .pyc, .md, .txt files, etc).

Now pre-commit initialization fails because it cannot create its virtual environment. I also cannot use virtualenv directly:

$ python -m virtualenv foo2
StopIteration:

Solution

The issue is caused by the removal of entry_points.txt from site-packages/virtualenv-20.17.0.dist-info/.

This files defines entry points, including console_scripts ones that allow the shell to call appropriate functions (source).



Answered By - Marek Grzenkowicz
Answer Checked By - Marilyn (WPSolving Volunteer)