0

I have used my code from time to time without any issues; however, I have just got trouble with pd.read_excel(path), where the path is a string that is the full path pointing to a .xlsx file. I can make sure that the syntax is valid and also that is the same code I used for my project.

When I run the code, the following is shown:

Traceback (most recent call last):

  File "C:\Users\PhucHH\AppData\Roaming\Python\Python39\site-packages\IPython\core\interactiveshell.py", line 3441, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "C:\Users\PhucHH\AppData\Local\Temp/ipykernel_2732/4217447866.py", line 6, in <module>
    df = pd.read_excel(fullPath)

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 364, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\excel\_base.py", line 1178, in __init__
    if import_optional_dependency("xlrd", errors="ignore") is None:

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\compat\_optional.py", line 115, in import_optional_dependency
    module = importlib.import_module(name)

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 786, in exec_module

  File "<frozen importlib._bootstrap_external>", line 923, in get_code

  File "<frozen importlib._bootstrap_external>", line 853, in source_to_code

  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

  File "C:\Users\PhucHH\AppData\Local\Programs\Python\Python39\lib\site-packages\xlrd\__init__.py", line 1187
    print "EXTERNSHEET(b7-):"
          ^
SyntaxError: invalid syntax

Thank you very much for help.

  • 3
    You're running Python 2 code with Python 3. `print` was a statement in Python 2, but became a function in Python 3. – Brian Dec 10 '21 at 16:34

0 Answers0