Trying to install packages using poetry And getting :
Current Python version (3.10.4) is not allowed by the project (>=3.8,<3.10).
Then I'm trying to do:
poetry env use python3.8
Or
poetry env use 3.8
And the same error popping. Any reason this could happen?
Make sure that when you are switching python version you are using a full path, so poetry has no problem with resolving the version:
poetry env use /usr/bin/python3.8
If that didn't help, check your pyproject.toml and make sure that the version of python is compatible, something like:
python = "^3.8"
If that's not the case try setting up global version:
pyenv global 3.8.15
Also, make sure that all the utility tools are compatible with expected python version:
sudo apt-get install python3.8-distutils
apt install build-essential libssl-dev libffi-dev python3-dev -y
I would advice to try upgrading the poetry, they have bugs from time to time.
I had a similar problem with poetry 2.1.2 version on Mac (poetry installed "globally" via brew). Then I tried to switch the current default python3 (linked to 3.11) it gave an error:
$ poetry env use /opt/homebrew/bin/python3.12
Current Python version (3.11.6) is not allowed by the project (^3.12).
Please change python executable via the "env use" command.
Then I had upgraded the poetry to 2.1.4:
$ brew upgrade poetry
...
$ poetry --version
Poetry (version 2.1.4)
It worked fine:
$ poetry env use /opt/homebrew/bin/python3.12
Using virtualenv: /Users/.../Library/Caches/pypoetry/virtualenvs/...-6xh79vL2-py3.12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With