Chanchal Roshan
Chanchal Roshan

Reputation: 174

Invalid syntax when importing openpyxl

Python 2.7.5 (default, Sep 26 2019, 13:23:47)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openpyxl

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<user>/.local/lib/python2.7/site-packages/openpyxl/__init__.py", line 6, in <module>
    from openpyxl.workbook import Workbook
  File "<user>/.local/lib/python2.7/site-packages/openpyxl/workbook/__init__.py", line 4, in <module>
    from .workbook import Workbook
  File "<user>/.local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 7, in <module>
    from openpyxl.worksheet.worksheet import Worksheet
  File "<user>/.local/lib/python2.7/site-packages/openpyxl/worksheet/worksheet.py", line 396
    return f"{get_column_letter(min_col)}{min_row}:{get_column_letter(max_col)}{max_row}"

Is there any additional packages needs to be installed?

Can anyone let me know the reason behind this behavior, since it is working fine on windows and macos.

Upvotes: 2

Views: 4347

Answers (1)

jarmod
jarmod

Reputation: 78653

The openpyxl package you've installed uses f-strings. They appeared in Python 3.6. You should switch from Python 2.7.5 to Python 3.6 or later. Or find an openpyxl package version that's compatible with Python 2.x.

Upvotes: 5

Related Questions