Since the release of v4.67.2, tqdm is broken on Python 3.7. It seems the new version attempts to import metadata from the standard importlib library, which was not introduced until Python 3.8.
D:\>python --version
Python 3.7.7
D:\>python -m virtualenv --version
virtualenv 20.26.6 from C:\Data\4_software\Portable\Python\3.7.7\lib\site-packages\virtualenv\__init__.py
D:\>python -m virtualenv .venv_for_test_tqdm_import_error
created virtual environment CPython3.7.7.final.0-64 in 726ms
creator CPython3Windows(dest=D:\.venv_for_test_tqdm_import_error, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=J:\Data\4_software\Portable\Msys2\home\Administrator\AppData\Local\pypa\virtualenv)
added seed packages: pip==24.0, setuptools==68.0.0, wheel==0.42.0
activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
D:\>.venv_for_test_tqdm_import_error\Scripts\activate
(.venv_for_test_tqdm_import_error) D:\>pip list
Package Version
---------- -------
pip 24.0
setuptools 68.0.0
wheel 0.42.0
(.venv_for_test_tqdm_import_error) D:\>pip install tqdm==4.67.2
Collecting tqdm==4.67.2
Using cached tqdm-4.67.2-py3-none-any.whl.metadata (57 kB)
Collecting colorama (from tqdm==4.67.2)
Using cached colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)
Using cached tqdm-4.67.2-py3-none-any.whl (78 kB)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Installing collected packages: colorama, tqdm
Successfully installed colorama-0.4.6 tqdm-4.67.2
(.venv_for_test_tqdm_import_error) D:\>pip list
Package Version
---------- -------
colorama 0.4.6
pip 24.0
setuptools 68.0.0
tqdm 4.67.2
wheel 0.42.0
(.venv_for_test_tqdm_import_error) D:\>python -c "import tqdm"
Traceback (most recent call last):
File "D:\.venv_for_test_tqdm_import_error\lib\site-packages\tqdm\version.py", line 3, in <module>
from importlib.metadata import PackageNotFoundError, version
ModuleNotFoundError: No module named 'importlib.metadata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\.venv_for_test_tqdm_import_error\lib\site-packages\tqdm\__init__.py", line 3, in <module>
from .cli import main # TODO: remove in v5.0.0
File "D:\.venv_for_test_tqdm_import_error\lib\site-packages\tqdm\cli.py", line 11, in <module>
from .version import __version__
File "D:\.venv_for_test_tqdm_import_error\lib\site-packages\tqdm\version.py", line 5, in <module>
from importlib_metadata import PackageNotFoundError, version
ModuleNotFoundError: No module named 'importlib_metadata'
(.venv_for_test_tqdm_import_error) D:\>pip install tqdm==4.67.1
Collecting tqdm==4.67.1
Using cached tqdm-4.67.1-py3-none-any.whl.metadata (57 kB)
Requirement already satisfied: colorama in d:\.venv_for_test_tqdm_import_error\lib\site-packages (from tqdm==4.67.1) (0.4.6)
Using cached tqdm-4.67.1-py3-none-any.whl (78 kB)
Installing collected packages: tqdm
Attempting uninstall: tqdm
Found existing installation: tqdm 4.67.2
Uninstalling tqdm-4.67.2:
Successfully uninstalled tqdm-4.67.2
Successfully installed tqdm-4.67.1
(.venv_for_test_tqdm_import_error) D:\>pip list
Package Version
---------- -------
colorama 0.4.6
pip 24.0
setuptools 68.0.0
tqdm 4.67.1
wheel 0.42.0
(.venv_for_test_tqdm_import_error) D:\>python -c "import tqdm"
(.venv_for_test_tqdm_import_error) D:\>
Since the release of v4.67.2, tqdm is broken on Python 3.7. It seems the new version attempts to import metadata from the standard importlib library, which was not introduced until Python 3.8.
read the known issues
environment, where applicable:
Since I cannot import tqdm, here is the manual environment info:
In tqdm/version.py(changed in release 4.67.2: https://github.com/tqdm/tqdm/pull/1704/changes#diff-689bd83ef38098c85bf4e5d41d964dfc3ab83dcbce7dd39b2a588794e6f526cfL3), the import logic for metadata should probably check the Python version and fallback to importlib_metadata for Python < 3.8, and importlib-metadata should be explicitly listed in install_requires for these versions.