pythonpandasubuntu

Ubuntu 22.04 syntax warning importing Pandas


I have installed Python 3.12 in Ubuntu 22.04 alongside the system Python 3.10. It works as expected as do packages such as Numpy. However after installing Pandas 2.2.2 the line import pandas as pd produces the warning message below. Pandas still then works as expected with Python 3.12. Why does this happen and what should I do?

/usr/lib/python3/dist-packages/pytz/__init__.py:31: SyntaxWarning: invalid escape sequence '\s'
  match = re.match("^#\s*version\s*([0-9a-z]*)\s*$", line)

Solution

  • Any explanations or guidance on something I should do would be welcome.

    /usr/lib/python3/dist-packages/pytz/__init__.py:31: SyntaxWarning: invalid escape sequence '\s' match =
    re.match("^#\s*version\s*([0-9a-z]*)\s*$", line)
    

    Problem comes from pytz, which claims (as of today) to support python 3.12, therefore warning should be gone after you install newest version, which as of today is 2024.2 which can be installed by doing

    pip install pytz==2024.2
    

    If warning will persist you might inform pytz authors about that.