pythonpython-3.9

Matplotlib requires dateutil


I installed matplotlib, tried to run the program, and get an error:

Traceback (most recent call last):
  File "C:\Users\kystepa2\Desktop\NEXTSY_PROJECT\TEST\mtsa\plot_metrics_mtsa.py", line 2, in <module>
    from matplotlib import pyplot
  File "C:\Users\kystepa2\Desktop\NEXTSY_PROJECT\venv\lib\site-packages\matplotlib\__init__.py", line 263, in <module>
    _check_versions()
  File "C:\Users\kystepa2\Desktop\NEXTSY_PROJECT\venv\lib\site-packages\matplotlib\__init__.py", line 259, in _check_versions
    raise ImportError(f"Matplotlib requires {modname}>={minver}; "
ImportError: Matplotlib requires dateutil>=2.7; you have 2.2

I checked that the installed version of python-dateutil is indeed 2.9.0:

C:\Users\kystepa2>pip show python-dateutil
Name: python-dateutil
Version: 2.9.0.post0

I tried reinstalling matplotlib and python-dateutil, but the error is still the same.

I tried installing dateutil instead of python-dateutil but got an error:

C:\Users\kystepa2>pip install dateutil
ERROR: Could not find a version that satisfies the requirement dateutil (from versions: none)
ERROR: No matching distribution found for dateutil

Solution

  • In Powershell first change directory to your project by running the following command:

    cd C:\Users\kystepa2\Desktop\NEXTSY_PROJECT

    While in this directory run venv\Scripts\activate to activate your venv.

    Now that your venv is activated run py -m pip install --upgrade python-dateutil to upgrade the package to its latest version in the venv.