user3556757
user3556757

Reputation: 3609

No Excel writer 'openpyxl' while using pandas.to_excel()

I'm using the Enthought Canopy python installation.

I've added the xlwt, xlrd, and openpyxl packages.

Make a very simple DataFrame and try to write it to two types of excel formats -- fn.xls and fn.xlsx

writing to fn.xls (which uses the xlwt package) works.

But trying to write fn.xlsx (which uses the openpyxl? or xlrd?) package fails with complaint: ValueError: No Excel writer 'openpyxl'

data = {'year': [2010, 2011, 2012, 2011, 2012, 2010, 2011, 2012],
        'team': ['Bears', 'Bears', 'Bears', 'Packers', 'Packers', 'Lions', 'Lions', 'Lions'],
        'wins': [11, 8, 10, 15, 11, 6, 10, 4],
        'losses': [5, 8, 6, 1, 5, 10, 6, 12]}
football = pd.DataFrame(data, columns=['year', 'team', 'wins', 'losses'])
print football

#works
football.to_excel('football.xls', index=False)
#fails:  ValueError: No Excel writer 'openpyxl' 
football.to_excel('football.xlsx', index=False)

output of pd.show_versions():

output of pd.show_versions(): pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Darwin
OS-release: 14.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.0
nose: 1.3.0
Cython: None
numpy: 1.8.0
scipy: 0.14.0
statsmodels: None
IPython: 2.3.0
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2013.8
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.3.1
openpyxl: 2.0.3
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
bq: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None

and I just notice a user_warning on startup...

/Users/slater/canopy_64/User/lib/python2.7/site-packages/pandas/io/excel.py:626:

UserWarning: Installed openpyxl is not supported at this time.

Use >=1.6.1 and <2.0.0. .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))

Not sure why enthought canopy would put incompatible versions of packages inside the same deployment package....

Upvotes: 1

Views: 4394

Answers (1)

user3556757
user3556757

Reputation: 3609

https://support.enthought.com/entries/46335594--RESOLVED-Pandas-Installed-openpyxl-is-not-supported-at-this-time-version-warning-

Canopy subscribers only: Note that if you are actually using openpyxl to read spreadsheets in pandas, then due to continuing limitations in pandas, you must downgrade openpyxl

Upvotes: 1

Related Questions