Problem importing xlsxwriter when using pandas Excelwriter

I am using pandas in a flask app. One of the lines is:

writer = pd.ExcelWriter(output, engine='xlsxwriter')

However it is giving an import error for the 'xlswriter':

File "/home/seapp/.local/lib/python3.5/site-packages/pandas/io/", line 1718, in init import xlsxwriter ImportError: No module named 'xlsxwriter'

What should I do to overcome this? I've just tested importing xlswriter to my local area but it did not solve the problem.

Thank you

You probably just need to install xlsxwriter.

I've mentioned that in the message: I've just tested importing xlswriter to my local area but it did not solve the problem.

Any other suggestion?

Ok. Let's agree on using import to describe what happens when you have the line "import something" in Python and install to mean making the module available through, for example, typing "pip install something" in a Bash console. Otherwise it's going to be very confusing.

When I installed xlsxwriter using pip3.5 install --user xlsxwriter that line of code worked fine. So it seems like maybe either you haven't installed it or perhaps your install is broken in some way. Perhaps try uninstalling it.

So make sure that you have installed xlsxwriter into the version of Python that you're running. It looks like 3.5, so you can use the install command I used above.

I am seeing this too - when using pytest!

I have created a virtual environment. pytest, pandas and xlsxwriter are installed within the virtual env.

From within the virtual env bash console, I can start python, and import xlsxwriter successfully.

However, running pytest within the environment, is failing on importing xlsxwriter.

What is going on?

Could you give a few more details about what you mean by "running pytest within the environment"? Are you running it from the virtualenv bash console that you started from the "Web" page?