python-poetry / python-poetry/poetry
Bug on poetry install `ValueError: invalid literal for int() with base 10: ''`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
Description
Similar to https://github.com/python-poetry/poetry/issues/6861, but clearing the cache in our case did not work
Upon poetry install, poetry fails its install because of a parsing error. It only happens for one of our crew mate, not for all of us.
Here is an excerpt of the error (the full error stack is available below)
at ~/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/poetry/utils/env/base_env.py:453 in _run
452│ except CalledProcessError as e:
→ 453│ raise EnvCommandError(e)
454│
Cannot install asgiref.
Stack trace:
...
CalledProcessError
Command '['/Users/mouhamadougaye/Documents/Abu-Dhabi-Customs/backend/.venv/bin/python', '-I', '-W', 'ignore', '-c', '\nimport importlib.util\nimport json\nimport sys\n\nfrom pathlib import Path\n\nspec = importlib.util.spec_from_file_location(\n "packaging", Path(r"/Users/mouhamadougaye/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/packaging/__init__.py")\n)\npackaging = importlib.util.module_from_spec(spec)\nsys.modules[spec.name] = packaging\n\nspec = importlib.util.spec_from_file_location(\n "packaging.tags", Path(r"/Users/mouhamadougaye/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/packaging/tags.py")\n)\npackaging_tags = importlib.util.module_from_spec(spec)\nspec.loader.exec_module(packaging_tags)\n\nprint(json.dumps(list(packaging_tags.platform_tags())))\n']' returned non-zero exit status 1.
at /Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/subprocess.py:578 in run
577│ if check and retcode:
→ 578│ raise CalledProcessError(retcode, process.args,
579│ output=stdout, stderr=stderr)
The following error occurred when trying to handle this error:
Stack trace:
...
1 ~/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/poetry/utils/env/virtual_env.py:119 in _run
118│ kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
→ 119│ return super()._run(cmd, **kwargs)
120│
EnvCommandError
Command ['/Users/mouhamadougaye/Documents/Abu-Dhabi-Customs/backend/.venv/bin/python', '-I', '-W', 'ignore', '-c', '\nimport importlib.util\nimport json\nimport sys\n\nfrom pathlib import Path\n\nspec = importlib.util.spec_from_file_location(\n "packaging", Path(r"/Users/mouhamadougaye/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/packaging/__init__.py")\n)\npackaging = importlib.util.module_from_spec(spec)\nsys.modules[spec.name] = packaging\n\nspec = importlib.util.spec_from_file_location(\n "packaging.tags", Path(r"/Users/mouhamadougaye/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/packaging/tags.py")\n)\npackaging_tags = importlib.util.module_from_spec(spec)\nspec.loader.exec_module(packaging_tags)\n\nprint(json.dumps(list(packaging_tags.platform_tags())))\n'] errored with the following return code 1
Error output:
Traceback (most recent call last):
File "<string>", line 20, in <module>
print(json.dumps(list(packaging_tags.platform_tags())))
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mouhamadougaye/Library/Application Support/pypoetry/venv/lib/python3.14/site-packages/packaging/tags.py", line 604, in mac_platforms
version = cast("AppleVersion", tuple(map(int, version_str.split(".")[:2])))
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
Workarounds
no workarounds
Poetry Installation Method
pipx
Operating System
MacOS 10.15.1
Poetry Version
2.4.1
Poetry Configuration
cache-dir = "/Users/mouhamadougaye/Library/Caches/pypoetry"
data-dir = "/Users/mouhamadougaye/Library/Application Support/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = false
keyring.enabled = true
python.installation-dir = "{data-dir}/python" # /Users/mouhamadougaye/Library/Application Support/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
solver.min-release-age = 0
solver.min-release-age-exclude = null
solver.min-release-age-exclude-source = null
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/mouhamadougaye/Library/Caches/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
Python Sysconfig
Example pyproject.toml
it is not a reproducable error, even with the same pyproject file. But for the sake of issue completion, here it is:
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "abu-dhabi-customs-backend"
version = "0.1.0"
description = "Backend API for Abu Dhabi Customs Management System"
requires-python = "~=3.14.0"
dependencies = [
"fastapi==0.136.0",
"python-multipart",
"aiohttp",
"uvicorn[standard]==0.48.0",
"pydantic==2.13.0",
"pydantic-settings==2.13.0",
"sqlalchemy[asyncio]==2.0.50",
"greenlet",
"aioodbc",
"azure-search-documents>=12.0.0",
"azure-storage-blob>=12.0.0",
"azure-keyvault-secrets>=4.8.0",
"azure-identity>=1.17.0",
"azure-cognitiveservices-speech>=1.50.0",
"azure-monitor-opentelemetry",
"httpx>=0.27.0",
"azure-core-tracing-opentelemetry",
"opentelemetry-instrumentation-openai",
"openai",
"python-dotenv",
"better-exceptions",
"asgi_correlation_id",
"colorlog",
]
[dependency-groups]
test = [
"pytest",
"pytest-cov",
"pytest-mock",
]
types = [
"mypy", # static type checker
"celery-types",
"types-psutil",
]
dev = [
"asgiref",
"pre-commit",
"faker",
"poetry",
"ipython", # for notebooks development
"ipykernel", # for notebooks development
{include-group = "test"},
{include-group = "types"}
]
[tool.pytest.ini_options]
pythonpath = "."
[tool.ruff]
line-length = 90
indent-width = 4
[tool.ruff.format]
skip-magic-trailing-comma = true
[tool.ruff.lint]
# Only ignore variables named "_".
dummy-variable-rgx = "^_$"
ignore = [
"COM812", # Trailing comma missing
"D1", # Missing docstrings
"D417", # Missing argument description in the docstring
"E203", # Whitespace before punctuation
"N806", # Variable lowercase
"SLF001", # Private member accessed
]
[tool.ruff.lint.flake8-annotations]
ignore-fully-untyped = true
mypy-init-return = true
[tool.ruff.lint.flake8-unused-arguments]
ignore-variadic-names = true
[tool.ruff.lint.pydocstyle]
convention = "numpy"
[tool.ruff.lint.pylint]
max-args = 10
max-positional-args = 6
[tool.poetry]
package-mode = false
Poetry Runtime Logs
poetry-runtime.log
Paste the output of 'poetry -vvv <command>', over this line.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with poetry/utils/env/base_env.py around line 453 and poetry/utils/env/virtual_env.py around line 119, then inspect the packaging.tags.py mac_platforms stack trace. Compare the failing macOS 10.15.1 and Python 3.14 environment with a working environment, using the attached logs and sysconfig output. Done means the failure is reproducible and a regression test or documented fix covers the invalid platform-version parsing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100