poetry change python version to 3.x
Whenever you change dependencies by hand in your pyproject.toml
you have to take care of these points:
Run
poetry lock
afterwards or remove thepoetry.lock
file to force recreation of it. The reasons for this is, thatpoetry install
takes thepoetry.lock
as input if can find one and not thepyproject.toml
.If you change the python version and uses in-project virtualenv, remove the
.venv
before runningpoetry install
. poetry doesn't change the python version of a venv once it is created, because it uses the python version itself to create the virtualenv.
Poetry makes it super easy to work with different Python versions or virtual environments. The recommended way to specify your Python version according to Poetry docs is
poetry env use /path/to/preferred/python/version
You can get the path to your Python version by running
which python3.7
I had the same problem. I solve it by fixing the first line in the file /home/nordman/.poetry/bin/poetry
(nordman
is my local name).
Just change #!/usr/bin/env python
to #!/usr/bin/env python3