Poetry creates virtualenv with wrong version
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.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- macOS BigSur 11.6.1 (20G224):
- Poetry version 1.1.13:
- Seems unrelated to pyproject.toml
Issue
I’m trying to constrain the python version within 3.9.x using:
[tool.poetry.dependencies]
python = "~3.9.0"
I have a setup of poetry
+ pyenv
that has been working nicely so far, but poetry insists on using Python 3.10
.
It tells me that it’s using 3.9.9
but it runs python 3.10
. Somehow it creates the virtualenv with the wrong version.
Pyenv has been set with pyenv local 3.9.9
and seems to be working correctly
Things I’ve tried:
poetry env use 3.9.9
- Delete everything (lock, venv, even cloning again) and trying again
- tried to use another folder name (in case something was cached)
- Ran with -vvv to check if I had more output about the venv creation
Thanks for the help!!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Poetry doesn't use the correct version of Python - Stack Overflow
To change the specific version poetry is using you should use poetry env ... (e.g. python = ">=3.6.2 <3.7" ) after creating the...
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 >Python Virtual Environments tutorial using Virtualenv and Poetry
A mini-guided Python tutorial showing how to use virtual environment and why it's matters on virtualenv and poetry illustrated examples.
Read more >Configure a Poetry environment | PyCharm Documentation
Poetry is a tool that facilitates creating a Python virtual environment based on the project dependencies. You can declare the libraries your project ......
Read more >Poetry Advance - Python Biella Group
As a result of creating a virtualenv folder within the project, vscode will recognize that this is the default virtualenv to use rather...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t want to create a nearly duplicate issue, but the issue I’m having is slightly different. If y’all prefer, I’ll create a new issue.
Issue:
Running
curl -sSL https://install.python-poetry.org | python -
installs Poetry without any errors or apparent issues. However, any attempt to usepoetry new
orpoetry init
will choose the version of Python which which Poetry was installed, independent of which version of Python has been selected as global usingpyenv global <version>
.System
pyenv
version 2.2.3-1-g423de9aepoetry
version 1.1.13zsh
5.8Steps to reproduce:
Short-term Fix
If I use
poetry env use 3.8.5
or whatever other version I want, and then create/activate a virtual environment withpoetry shell
, Poetry uses the appropriate Python version. But I think this is not expected behavior, i.e., Poetry should (and on an Ubuntu system I’ve used previously, Poetry does) choose the version of Python based on the currently activated Python version perpyenv
.Hey,
this should now work correctly by setting
virtualenvs.prefer-active-python
totrue
.fin swimmer