Poetry trying to add wrong version of Pandas, how to resolve dependencies

Question:
I have a python program that uses Python 3.8. I may have added Pandas later after initial development. When I click to run the app now, the console displays:

--> poetry add pandas
Using version ^2.1.2 for pandas

Updating dependencies
Resolving dependencies...

  SolverProblemError

  The current project's Python requirement (>=3.8.0,<3.9) is not compatible with some of the required packages Python requirement:
    - pandas requires Python >=3.9, so it will not be satisfied for Python >=3.8.0,<3.9
  
  Because pandas (2.1.2) requires Python >=3.9
   and no versions of pandas match >2.1.2,<3.0.0, pandas is forbidden.
  So, because python-template depends on pandas (^2.1.2), version solving failed.....

This runs displays every time I run the app now.

If I check the poetry.lock file it says:

[[package]]
name = "pandas"
version = "1.4.4"
description = "Powerful data structures for data analysis, time series, and statistics"
category = "main"
optional = false
python-versions = ">=3.8"

This is not the version of Pandas that my console says it is trying to use when I run my app, as it says,

--> poetry add pandas
Using version ^2.1.2 for pandas

My question is as to how to get this error message to go away. Ideally I want to use a version of Pandas compatible with Python 3.8 and stop this Poetry add pandas error from showing up each time I run my app. I suppose another option if possible would be to upgrade the repl to Python 3.9 if that is possible. Any insight appreciated.

Update:
I added pandas = "1.4.4" to the pyproject.toml file under [tool.poetry.dependencies] and it made the console poetry error go away, however… If I check my Packages tab it does not list Pandas as being installed. Is Pandas installed? Did I solve the problem or did I just do something to make the error invisible?

If you’d like to stick with python 3.8, then that will work fine. The packager just doesn’t understand that you manually corrected it.

If you’d like to switch to 3.12, you could simply make a new python Repl.

If you’d like 3.10, I have a Repl for this, here.

I don’t appear to have a backed up copy of 3.9, perhaps someone else does.

1 Like

Ok, I guess I wasn’t sure exactly what adding a package directly to the pyproject.toml file does. If that installs the package but just doesn’t update the packager I am ok with that solution.

2 Likes

If you would like to add an older version of Pandas (because newer versions require python>=3.9), then you can try:

poetry add pandas==1.4.4

If you edit the pyproject.toml file, nothing is installed or updated until you “update” poetry (such as with poetry install or poetry add ...). Poetry won’t install the package if it is not updated (it must go through dependency resolving to install something).

I would recommend moving to the newer python templates, which use python 3.10.

1 Like

Which the auto-package installation will do once it tries to load pandas.

I’m pretty sure the new defaults use 3.12.

1 Like

For me the official template still uses python 3.10.11

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.