question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry does not use active pyenv when creating virtual environment

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • OS version and name: MacOS 10.14 Mojave

  • Poetry version: 0.12.8

Issue

I have a project directory with a .python-version file like this:

3.7.1

Poetry has been installed into Python 3.6.5. According to recent comments, poetry is supposed to detect the active Python version when creating a new virtual environment, but it seems to stick with 3.6.5 all the time. To illustrate:

$ python --version
Python 3.7.1
$ poetry run python --version
Python 3.6.5

When I specify python = "^3.7" in `pyproject.toml I get an error:

$ poetry shell

[RuntimeError]
The current Python version (3.6.5) is not supported by the project (^3.7)
Please activate a compatible Python version.

shell

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:30
  • Comments:53 (20 by maintainers)

github_iconTop GitHub Comments

30reactions
PiQuercommented, Mar 20, 2022

Thanks @princelySid. That would be poetry env use $(pyenv which python) for pyenv users with an active pyenv interpreter.

27reactions
hute37commented, Jun 15, 2021

poetry installed with install-poetry.py to enable poetry self update. Same problem with pyenv python version.

It seems to work with explicit virtual env creation with:


poetry env use -- $(which python)

# Creating virtualenv ...-VfhLuGbT-py3.7 in .../.cache/pypoetry/virtualenvs
# Using virtualenv: .../.cache/pypoetry/virtualenvs/...-VfhLuGbT-py3.7

Versions:


poetry --version
# Poetry (version 1.2.0a1)

pyenv --version
#  pyenv 2.0.1-3-g1706436f

pyenv  versions  
#  system
# * 3.7.6 (set by PYENV_VERSION environment variable)
#   3.9.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Poetry with PyEnv and having Python version issues
I can do a pyenv local 3.10.0 without any issue and the project uses it. But using the poetry env use command errors...
Read more >
Managing environments | Documentation - Poetry
By default, Poetry will try to use the Python version used during Poetry's installation to create the virtual environment for the current project....
Read more >
Why You Should Use Pyenv & Poetry for Python Projects
Poetry is much more than the virtual environment. When you initialize the project with Poetry it creates a virtual environment specific to the...
Read more >
Setting Up Python: pyenv, pyenv-virtualenv, poetry
These are steps to install and set up Python on a Mac. ... Manager: pyenv; Virtual Environment: pyenv-virtualenv; Package Manager: poetry.
Read more >
A Poetic Apology. Or Why Should You Use Poetry to Manage…
Since this is not your first Python project and you want to avoid spending more ... pyenv-virtualenv, which makes managing venvs even more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found