Python 3 virtual environment creation apparently hangs for a few minutes before completing

Viewed 51

When I run the command python -m venv my_venv to create a new virtual environment, the command takes about 5 minutes to complete. However, the resulting virtual environment seems correct and usable.

By inspecting the process with pstree, it seems that it hangs when running the following code:

import runpy
import sys
sys.path = ['/var/folders/gq/9lxcx1kj60qgjsz_4spdzs6m0000gn/T/tmp90w5k5m8/setuptools-59.0.1-py3-none-any.whl', '/var/folders/gq/9lxcx1kj60qgjsz_4spdzs6m0000gn/T/tmp90w5k5m8/pip-21.3.1-py3-none-any.whl'] + sys.path
sys.argv[1:] = ['install', '--no-cache-dir', '--no-index', '--find-links', '/var/folders/gq/9lxcx1kj60qgjsz_4spdzs6m0000gn/T/tmp90w5k5m8', '--upgrade', 'setuptools', 'pip']
runpy.run_module("pip", run_name="__main__", alter_sys=True)

I'm experiencing this problem on a new Macbook Pro with the Apple M1 chip and macOS Monterey 12.1. I've tried a few different Python 3.x versions (3.7, 3.8, 3.9), installed both with brew and pyenv, all with the same result.

Note also that this problem doesn't occur when creating a virtual environment using the virtualenv command, i.e., in this case it takes only a few seconds.

0 Answers
Related