AttributeError with virtualenv version 20.33.1: 'PythonInfo' object has no attribute 'tcl_lib'
Description
AttributeError
'PythonInfo' object has no attribute 'tcl_lib'
at /opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/site-packages/virtualenv/activation/via_template.py:50 in replacements
46│ "__VIRTUAL_ENV__": str(creator.dest),
47│ "__VIRTUAL_NAME__": creator.env_name,
48│ "__BIN_NAME__": str(creator.bin_dir.relative_to(creator.dest)),
49│ "__PATH_SEP__": os.pathsep,
→ 50│ "__TCL_LIBRARY__": creator.interpreter.tcl_lib or "",
51│ "__TK_LIBRARY__": creator.interpreter.tk_lib or "",
52│ }
53│
54│ def _generate(self, replacements, templates, to_folder, creator):
- OS: Ubuntu
- Shell: GitHub Actions
- Python version and path: 3.12.11
Here is an example project/run that fails: https://github.com/douwevandermeij/test-virtualenv/actions/runs/16797823289/job/47572059324
Also reported here: https://github.com/pypa/virtualenv/issues/2944 with PR https://github.com/pypa/virtualenv/pull/2945
Workarounds
Downgrade virtualenv to 20.32.0
Poetry Installation Method
pip
Operating System
Ubuntu 24.04.2 LTS
Poetry Version
2.1.4
Poetry Configuration
see github action log
Python Sysconfig
sysconfig.log
Paste the output of 'python -m sysconfig', over this line.
Example pyproject.toml
[tool.poetry]
name = "test-virtualenv"
version = "0.0.1"
description = ""
authors = ["Douwe van der Meij <[email protected]>"]
exclude = []
[tool.poetry.dependencies]
python = "~3.12"
python-dotenv = "*"
fractal-toolkit = "*"
pydantic = "*"
fastapi = "*"
uvicorn = "*"
firebase-admin = "*"
httpx = "*"
sentry-sdk = {version = "*", extras = ["fastapi"]}
python-jose = {version = "*", extras = ["cryptography"]}
python-multipart = "*"
google-cloud-pubsub = "*"
google-cloud-secret-manager = "*"
jinja2 = "*"
requests = "*"
python-dateutil = "*"
jwcrypto = "*"
[tool.poetry.group.dev.dependencies]
autoflake = "*"
black = "*"
flake8 = "*"
isort = "*"
pre-commit = "*"
pylint = "*"
pytest = "*"
pytest-cov = "*"
pytest-env = "*"
pytest-sugar = "*"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
see https://github.com/douwevandermeij/test-virtualenv/blob/main/pyproject.toml
Poetry Runtime Logs
poetry-runtime.log
Paste the output of 'poetry -vvv <command>', over this line.
you'll want to report this to virtualenv, not here
As already mentioned, this seems to be an issue in virtualenv 20.33.1. It is tracked there in pypa/virtualenv#2944
Further, Poetry 2.1.4 does not even allow virtualenv 20.33.1: https://github.com/python-poetry/poetry/blob/2.1.4/pyproject.toml#L31
When installing Poetry 2.1.4 as described in the docs, it will not install virtualenv 20.33.1
Unfortunately, with Poetry 2.1.4 poetry update will install virtualenv 20.33.1 even when Poetry itself is running with virtualenv 20.32.0. I temporarily resolved this issue by modifying pyproject.toml to have the same pin (virtualenv = ">=20.26.6,<20.33.0").
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.