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 incorrectly identifies python version requirement #5077

Closed
3 tasks done
chaosct opened this issue Jan 21, 2022 · 5 comments · Fixed by #5086
Closed
3 tasks done

poetry incorrectly identifies python version requirement #5077

chaosct opened this issue Jan 21, 2022 · 5 comments · Fixed by #5086
Labels
kind/bug Something isn't working as expected

Comments

@chaosct
Copy link

chaosct commented Jan 21, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Raspbian GNU/Linux 10 (buster)
  • Poetry version: 1.1.12
  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

poetry run does not honor poetry env:

$ pyenv local
3.9.10
$ python --version
Python 3.9.10
$ poetry env use python3.9
Using virtualenv: /home/pi/.cache/pypoetry/virtualenvs/ppx-node-production-tool-8PNkRAxl-py3.9
$ poetry run python --version
Python 3.7.3

This causes that some parts of a poetry install command use the 3.9 version of python but others not:

$ poetry install
Updating dependencies
Resolving dependencies... (10.9s)

Writing lock file

  SolverProblemError

  The current project's Python requirement (3.7.3) is not compatible with some of the required packages Python requirement:
    - ppx-remote requires Python >=3.9,<4.0, so it will not be satisfied for Python 3.7.3

  Because ppx-remote (0.3.0) requires Python >=3.9,<4.0
   and no versions of ppx-remote match !=0.3.0, ppx-remote is forbidden.
  So, because ppx-node-production-tool depends on ppx-remote (*), version solving failed.
...

As you can see, the python version requirement is not correctly identified. pyproject.toml specifies python = "^3.9"

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

Hello @chaosct,

is there a .venv folder in your project folder?

fin swimmer

@chaosct
Copy link
Author

chaosct commented Jan 21, 2022

Hi @finswimmer !

there is no .env folder in the project.

But I noted this: the env was not correctly created

$ /home/pi/.cache/pypoetry/virtualenvs/ppx-node-production-tool-8PNkRAxl-py3.9/bin/python --version
Python 3.7.3

And this solves the problem:

$ poetry env remove python3.9
Deleted virtualenv: /home/pi/.cache/pypoetry/virtualenvs/ppx-node-production-tool-8PNkRAxl-py3.9
$ python3.9 --version
Python 3.9.10
$ poetry env use python3.9
Creating virtualenv ppx-node-production-tool-8PNkRAxl-py3.9 in /home/pi/.cache/pypoetry/virtualenvs
Using virtualenv: /home/pi/.cache/pypoetry/virtualenvs/ppx-node-production-tool-8PNkRAxl-py3.9
$ /home/pi/.cache/pypoetry/virtualenvs/ppx-node-production-tool-8PNkRAxl-py3.9/bin/python --version
Python 3.9.10
$ poetry run python --version
Python 3.9.10

I don't really understand why the wrong virtualenv was created in the first place. Some issue with pyenv?

I think it would be a good thing to check for inconsistencies when creating envs.

Anyway thanks!

Should I close the issue even though I don't know what caused it?

@finswimmer
Copy link
Member

I think this is what happend:

I think you have installed poetry with install-poetry.py. There, poetry is not able to detect the activated python by pyenv (This will change in the next pre-release #4852).

You then switched your current python with pyenv and run poetry env use python. Poetry took the version number from the python in the current shell, but this python cannot be used to create the new venv. Instead there the python used during installation of poetry is used.

I would keep this open, because poetry should create a venv with the name of the interpreter it uses.

fin swimmer

@chaosct
Copy link
Author

chaosct commented Jan 21, 2022

I think you are pretty right @finswimmer

But basically, initially I installed poetry and when I noticed that I needed another python version I installed pyenv. So poetry could not know about pyenv.

I re-created the env after uninstalling and reinstalling poetry.

Thanks for your awesome work!

Copy link

github-actions bot commented Mar 2, 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 2, 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

Successfully merging a pull request may close this issue.

3 participants