Search code examples
pythonpandaspycharm

Why is PyCharm asking for old version of Pandas and how can I make it stop?


I am trying to learn Pandas, and am doing a simple project in PyCharm, but PyCharm is saying there is an error because I am not using specific out-of-date versions of Pandas, NumPy, and Faker. I do not know what Faker is. You can see the error message and my code below, though my code doesn't matter much to my question. enter image description here The code still runs as expected, but I want to understand if I'm setting up problems for the future.

I tried googling this, but I don't know what keywords I should be searching.


Solution

  • From what I've encountered in the past, this usually means that there is either a requirements.txt or a pyproject.toml, or a similar file in your project directory. These files define what versions of required packages the project was built for to let the user know that if they have a version different than that, the developer cannot guarantee the code will work.

    At least for the commonly used styles, regardless of the style of requirements file a project has, there will be lines included in it such as what you are seeing in that warning banner from PyCharm. These will look like

    numpy == 1.18.4
    pandas == 1.0.4
    ... other package requirements ...
    

    The reason it is showing a warning is because these requirements are listed as strong equalities, meaning that the developer is indicating that these versions of these packages are the ONLY version that they guarantee the code will work with.

    But this isn't the only requirement type that can be listed - there is also >= meaning it needs to be at least the listed version, <= for at most, etc. From what I've seen though, the syntax of the requirements file may vary a bit between styles though I don't know this for certain. I would recommend looking up the syntax of whatever specific requirements file you have.

    Are you importing a custom package? I don't have time right now to test it to make sure, but I believe it's possible that an imported package that wasn't installed through pip or an environment manager such as conda can also trigger these kinda of warnings (such as in the case of downloading source code from GitHub and including it in your project)

    (As a side note, it looks like there are a few different file conventions that can be used, though I don't know what files PyCharm will autodetect the less common ones. From what I was able to find in the Pycharm docs, it seems that you can point PyCharm to whatever requirements file you have if it fails to autodetect it.)