Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make poetry install the Python version required in pyproject.toml?

One thing about poetry seems really odd to me:

When you install poetry, it installs the latest Python version and uses this as a default for all poetry projects. If a different Python version is required as per a per the project's pyproject.toml, the poetry documentation states that you must point poetry to a suitable Python executable via poetry env use.

But that means that you need to already have said Python version installed manually.

Isn't the whole point of a dependency manager to install all the right dependency versions for you inside the virtual environment, including the required Python version?

Is there a way to get poetry to install the right Python version automatically or do I have to manually manage the various Python versions that all my poetry projects require?

like image 465
Alex Avatar asked Oct 20 '25 23:10

Alex


1 Answers

poetry does not install new versions of Python on your machine. It creates a virtual environment using a version of Python you already have installed. The purpose of storing a required Python version in pyproject.toml is to have that information available for your package's metadata when you build the package.

You (or the package manager of your choice) remain responsible for ensuring that a necessary version of Python is on your machine and available for use by poetry.

like image 142
chepner Avatar answered Oct 22 '25 13:10

chepner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!