Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry proceeds although python version is incorrect #5286

Closed
cfra opened this issue Mar 8, 2022 · 3 comments
Closed

Poetry proceeds although python version is incorrect #5286

cfra opened this issue Mar 8, 2022 · 3 comments
Labels
kind/bug Something isn't working as expected

Comments

@cfra
Copy link

cfra commented Mar 8, 2022

General info

  • OS version and name: Arch Linux
  • Poetry version: 1.1.13

pyproject.toml

[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
python = ">=3.8,<3.10"
hcloud = "^1.10.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Issue

While system Python is 3.10, I have Python 3.9 available and active using pyenv.

Poetry correctly detects that the system Python version is incompatible with the Project and prints that it will use version 3.9, however the venv is created with the wrong python version:

$ cat .python-version
3.9.10
$ python
Python 3.9.10 (main, Feb  1 2022, 12:54:42)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ which python
/home/user/.pyenv/shims/python
$ /usr/bin/python
Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ poetry install # Poetry is 1.1.13
The currently activated Python version 3.10.2 is not supported by the project (>=3.8,<3.10).
Trying to find and use a compatible version.
Using python3 (3.9.10)
Creating virtualenv my-project-SwvjWCYu-py3.9 in /home/user/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

  SolverProblemError

  The current project's Python requirement (3.10.2) is not compatible with some of the required packages Python requirement:
    - hcloud requires Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.10, so it will not be satisfied for Python 3.10.2
# install fails
$ . /home/user/.cache/pypoetry/virtualenvs/my-project-SwvjWCYu-py3.9/bin/activate
(my-project-SwvjWCYu-py3.9) $ python
Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Recreating the venv with the correct python version seems to resolve this problem:

$ rm -rf /home/user/.cache/pypoetry/virtualenvs/my-project-SwvjWCYu-py3.9
$ python -m venv /home/user/.cache/pypoetry/virtualenvs/my-project-SwvjWCYu-py3.9
$ poetry install
The currently activated Python version 3.10.2 is not supported by the project (>=3.8,<3.10).
Trying to find and use a compatible version.«
Using python3 (3.9.10)
Installing dependencies from lock file

Package operations: 65 installs, 0 updates, 0 removals

# install succeeds fine

Although this seems somewhat related to #5252, it seems to me like this is indeed a slightly different bug:

If Poetry detects that 3.9 is required and creates a venv called 3.9, that venv should not be running 3.10.

@cfra cfra added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 8, 2022
@finswimmer
Copy link
Member

Hello @cfra,

I think you are affected by #5077 (comment) which is resolved by #5086.

fin swimmer

@cfra
Copy link
Author

cfra commented Mar 8, 2022

Yes, it sounds indeed like this is the case. Thank you for your prompt reply and keep up the great work. 👍

@cfra cfra closed this as completed Mar 8, 2022
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Jun 11, 2022
Copy link

github-actions bot commented Mar 1, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants