Skip to content

[Import Error] with openpyxl: specifically w/ pd.to_excel() #7183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
allentsouhuang opened this issue May 20, 2014 · 2 comments
Closed

[Import Error] with openpyxl: specifically w/ pd.to_excel() #7183

allentsouhuang opened this issue May 20, 2014 · 2 comments

Comments

@allentsouhuang
Copy link

from pandas.util.print_versions import show_versions
show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.5.final.0
python-bits: 64
OS: Darwin
OS-release: 13.1.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.13.1
Cython: None
numpy: 1.6.2
scipy: 0.11.0
statsmodels: None
IPython: 2.0.0
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 1.5
pytz: 2012d
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.1.1
openpyxl: 2.0.2
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: None
sqlalchemy: 0.9.4
lxml: None
bs4: None
html5lib: None
bq: None
apiclient: None

THE CODE

import pandas as pd
import numpy as np
dates = pd.date_range('20130101',periods=6)
df = pd.DataFrame(np.random.randn(6,4),index = dates, columns=list('ABCD'))
df.to_excel("foo.xlsx")

ERROR MESSAGE

Traceback (most recent call last):
File "test.py", line 5, in
df.to_excel("foo.xlsx")
File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 1204, in to_excel
startrow=startrow, startcol=startcol)
File "/Library/Python/2.7/site-packages/pandas/io/excel.py", line 530, in write_cells
style = self._convert_to_style(cell.style)
File "/Library/Python/2.7/site-packages/pandas/io/excel.py", line 577, in _convert_to_style
from openpyxl.style import Style
ImportError: No module named style

ANALYSIS

Went into my site packages --> openpyxl
Saw that the folder for style has been renamed to styles.
Did a reinstall of openpyxl with the same results.
Manually renamed to openpyxl.styles, but engendered more bugs (something about borders).
My hypothesis: openpyxl has changed their naming convention that broke the the Pandas.to_excel function.

@jreback
Copy link
Contributor

jreback commented May 20, 2014

thanks
this is a dupe of #7169
soln is to downgrade openpyxl, install xlsxwriter

pandas 0.14.0 will fix as well (2 weeks till release)

@jreback jreback closed this as completed May 20, 2014
@jreback
Copy link
Contributor

jreback commented May 20, 2014

you are right
openpyxl did an API change in version. 2
that breaks back compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants