BUILD: Getting Syntax error for pandas library import in python If not using virtual env

This issue has been tracked since 2022-09-20.

Installation check

Platform

Windows-10-10.0.19044-SP0

Installation Method

pip install

pandas Version

latest

Python Version

3.10.6

Installation Logs

If I use virtual env then everything is fine But if I run simply then getting syntax error for any kind of library import

Consider a simple pandas library import program

import pandas as pd




C:\Users\Keshav\Desktop\GAN_Assignment>python main.py
Traceback (most recent call last):
  File "C:\Users\Keshav\Desktop\GAN_Assignment\main.py", line 1, in <module>
    import pandas as pd
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat\__init__.py", line 15, in <module>      
    from pandas.compat.numpy import (
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat\numpy\__init__.py", line 4, in <module> 
    from pandas.util.version import Version
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\__init__.py", line 1, in <module>
    from pandas.util._decorators import (  # noqa:F401
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\_decorators.py", line 14, in <module>     
    from pandas._libs.properties import cache_readonly  # noqa:F401
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\_libs\__init__.py", line 13, in <module>       
    from pandas._libs.interval import Interval
  File "pandas\_libs\interval.pyx", line 1, in init pandas._libs.interval
  File "pandas\_libs\hashtable.pyx", line 1, in init pandas._libs.hashtable
  File "pandas\_libs\missing.pyx", line 1, in init pandas._libs.missing
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\_libs\tslibs\__init__.py", line 30, in <module>
    from pandas._libs.tslibs.conversion import (
  File "pandas\_libs\tslibs\conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
  File "pandas\_libs\tslibs\timezones.pyx", line 14, in init pandas._libs.tslibs.timezones
  File "C:\Users\Keshav\AppData\Local\Programs\Python\Python310\lib\site-packages\dateutil\tz.py", line 78
    `self._name`,
    ^
SyntaxError: invalid syntax

16b8583075ed5ab039e26ab7c6f49777160b4f53

lithomas1 wrote this answer on 2022-09-20

This looks like a problem with dateutil not pandas. Can you try pip uninstalling python-dateutil and reinstalling it?
Thanks.

phofl wrote this answer on 2022-09-29

Closing for now. Please ping to reopen, when you can answer questions

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-10-04
Star Count 35430
Watcher Count 1120
Fork Count 15089
Issue Count 3589

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date