Pandas: Can't import xlsxwriter

Created on 14 Nov 2018  路  2Comments  路  Source: pandas-dev/pandas

Code Sample, a copy-pastable example if possible

from io import BytesIO as IO
import pandas as pd

pd.__version__ # '0.23.4'

df = pd.DataFrame(columns=['a', 'b'])
excel_writer = IO()
xlsx = pd.ExcelWriter(ew, engine='xlsxwriter')

Problem description

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/o.solop/.pyenv/versions/3.6.5/lib/python3.6/site-packages/pandas/io/excel.py", line 1718, in __init__
    import xlsxwriter
ModuleNotFoundError: No module named 'xlsxwriter'

Expected Output

Not an error.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-138-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: 3.6.0
pip: 18.1
setuptools: 39.0.1
Cython: None
numpy: 1.15.2
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: 2.2.5
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Usage Question

All 2 comments

You don't have xlsxwriter installed hence the error

It's an optional dependency so you should try conda install xlsxwriter before using the engine

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BDannowitz picture BDannowitz  路  3Comments

nathanielatom picture nathanielatom  路  3Comments

amelio-vazquez-reina picture amelio-vazquez-reina  路  3Comments

ebran picture ebran  路  3Comments

Ashutosh-Srivastav picture Ashutosh-Srivastav  路  3Comments