Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print "EXTERNSHEET(b7-):" pandas

I was trying to run as ussually my library "pandas" but then I faced a mistake

import pandas as pd

DF_temp = pd.read_excel("example.xlsx")

Output

  File "/opt/anaconda3/lib/python3.7/site-packages/xlrd/__init__.py", line 1187
    print "EXTERNSHEET(b7-):"
                            ^
SyntaxError: invalid syntax

I am working with python 3.7

I installed again xlrd but the same issue appears. How can I resolve this? Thank you

like image 812
coding Avatar asked Aug 12 '20 02:08

coding


5 Answers

Had the same issue and used suggested fix python3 -m pip install --upgrade xlrd Worked for me even though I received some warning.

Defaulting to user installation because normal site-packages is not writeable
Collecting xlrd
  Downloading xlrd-1.2.0-py2.py3-none-any.whl (103 kB)
     |████████████████████████████████| 103 kB 6.0 MB/s eta 0:00:01
Installing collected packages: xlrd
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

camelot 12.6.29 requires SQLAlchemy<0.8.0,>=0.7.7, but you'll have sqlalchemy 1.3.14 which is incompatible.
camelot 12.6.29 requires xlrd==0.7.1, but you'll have xlrd 1.2.0 which is incompatible.
Successfully installed xlrd-1.2.0
Note: you may need to restart the kernel to use updated packages.
like image 155
Hugo Avatar answered Oct 24 '22 07:10

Hugo


Sometimes we should upgrade our pip before installing any new package. You can follow this command :

python.exe -m pip install --upgrade pip

After that, you can install xlrd package with the command:

pip install xlrd

Even after installing xlrd, you may face this same error again and again at that time please check proper extension of your excel file. Many time old version of excel throws error. It can be 'excel 5.0/95' file.

For this file you can install pyexcel or pyexcel_xls package to work ahead. You find the documentation of same in the link

use command:

pip install pyexcel 

or

pip install pyexcel_xls

I'm not sure that this will work perfectly but, we can explore ahead to resolve such errors and issues.

like image 23
Sarthak Niwate Avatar answered Oct 24 '22 06:10

Sarthak Niwate


It seems you are trying to read 'Microsoft Excel 97-2003 Worksheet' type.

Try to open the workbook with xlrd package and then read it using the pandas read_excel function.

Below is code snippet

wb = xlrd.open_workbook(file, logfile=open(devnull, 'w'))
df = df.append(pd.read_excel(wb, dtype=str, skiprows=1, engine='xlrd'), ignore_index=True)
like image 21
Mayur Chaudhari Avatar answered Oct 24 '22 05:10

Mayur Chaudhari


The solution for the problem is updating the xlrd library. Just run this command and the problem will be solved:

!pip install --upgrade xlrd
like image 1
Yash Patil Avatar answered Oct 24 '22 05:10

Yash Patil


I resolved this issue by downloading the updated pandas and xlrd packages.

  1. open anaconda prompt
  2. type pip show xlrd if the version is old then ,
  3. pip install xlrd==2.0.1 (the latest version)
like image 1
Agog Avatar answered Oct 24 '22 07:10

Agog