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 fails when Poetry's Python version differs from the active environment's Python version #354

Closed
3 tasks done
nchammas opened this issue Jul 29, 2018 · 7 comments
Closed
3 tasks done

Comments

@nchammas
Copy link
Contributor

  • 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: macOS 10.13.6

  • Poetry version: 0.11.3

  • Link of a Gist with the contents of your pyproject.toml file: not relevant

Issue

This is a minor issue. Poetry names the virtual environments it creates using the Python version it is running under, which I think is incorrect. Instead, it should use the Python version currently active.

For example, say I install Poetry with my Homebrewed Python, which is at Python 3.7.0. But inside a specific project, I have Python 3.6.6 activated via pyenv. This is what happens:

myproject$ python --version
Python 3.6.6
myproject$ which python
.../.pyenv/shims/python
myproject$ poetry shell
Creating virtualenv myproject-py3.7 in .../Library/Caches/pypoetry/virtualenvs
Spawning shell within .../Library/Caches/pypoetry/virtualenvs/myproject-py3.7
myproject$ python --version
Python 3.6.6

I believe the cause of this confusing discrepancy between the venv name and the active Python version is here. Instead of querying its own Python version, Poetry should query the version of the Python that would be invoked when it creates the virtual environment.

@nchammas
Copy link
Contributor Author

Hmm, this issue may be deeper than I thought. If I call poetry develop on a project setup in the above way, I get this error:

myproject$ poetry develop
Installing dependencies from lock file
<snipped>
[VenvCommandError]
Command ['pip', 'install', '-e', '.../myproject', '--no-deps'] errored with the following output:
Obtaining file:///.../myproject
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
myproject requires Python '>=3.4,<3.7' but the running Python is 3.7.0  # error here!
<pip version warning snipped>
myproject$ pip --version
pip 10.0.1 from .../.pyenv/versions/3.6.6/lib/python3.6/site-packages/pip (python 3.6)
myproject$ python --version
Python 3.6.6

I do have the following snippet in my pyproject.toml

[tool.poetry.dependencies]
python = ">=3.4, <3.7"

but I would expect Poetry to work since the active Python is Python 3.6.6. However, it seems that the faulty Python version detection I pointed to for poetry shell also affects poetry develop.

@nchammas
Copy link
Contributor Author

Looking again through past issues, what I'm describing here may be related to #172.

@nchammas nchammas changed the title Poetry names the venv it creates after Poetry's Python version instead of the project Python version poetry shell/develop look at Poetry's Python version instead of the active environment's Python version Aug 1, 2018
@nchammas nchammas changed the title poetry shell/develop look at Poetry's Python version instead of the active environment's Python version Poetry fails when Poetry's Python version differs from the active environment's Python version Aug 2, 2018
@nchammas
Copy link
Contributor Author

nchammas commented Mar 2, 2019

Hi @sdispater - Has this issue been resolved with a recent change? I don't see a recently linked PR that would explain the close.

@nchammas
Copy link
Contributor Author

nchammas commented Mar 5, 2019

Hey @sdispater, just checking in again to understand why this issue was closed, since it's not clear to me.

@nchammas
Copy link
Contributor Author

Hey @brycedrennan, I noticed you reopened #172. You may be interested in taking a quick look at this issue, which I believe is related.

@brycedrennan
Copy link
Contributor

Thanks for the example!

Copy link

github-actions bot commented Mar 3, 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 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants