pwned555
pwned555

Reputation: 702

ImportError: No module named xlsxwriter

I recently downloaded the xlsxwriter version 0.6.4 and installed it on my computer. It correctly added it to my C:\Python27\Lib\site-packages\xlsxwriter folder, however when I try to import it I get the error ImportError: No module named xlsxwriter. The traceback is File "F:\Working\ArcGIS\ArcGIS .py\Scripts\Append_Geodatabase.py".

However if I try to import numpy (I can't remember what numby is, however it is located in the same site-packages folder C:\Python27\Lib\site-packages\numpy) it has no problem.

Any idea of what could be causing this issue?

Thanks for the help.

Upvotes: 53

Views: 340776

Answers (10)

jmcnamara
jmcnamara

Reputation: 41574

Even if it looks like the module is installed, as far as Python is concerned it isn't since it throws that exception.

Try installing the module again using one of the installation methods shown in the XlsxWriter docs and look out for any installation errors.

If there are none then run a sample program like the following:

import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')

workbook.close()

If you still have a error after that then the most likely/common issue is that you have more than one version of Python installed (for example the system Python and another one used by an IDE) and the library has been installed in one and not the other.

Upvotes: 29

Rasqule
Rasqule

Reputation: 13

Using this on Raspberry Pi 4. I had a similar issue. I followed the install step:

sudo pip install xlsxwriter

None of the IDEs could find the module. I had to use Add/Remove Software under preferences in the GUI, search for xlsxwriter, select one by clicking on it and make sure the box is checked, and then click apply, then select the other one (it showed two for me) and click apply for that one. After that, it worked fine.

Upvotes: 1

Javadirad
Javadirad

Reputation: 21

in VSCode: instead of activating your environment with script use python select interpreter from VSCode(press ctrl + shift + p) and then select your environment from the list (marked with recommended)

Upvotes: 1

nordicherry
nordicherry

Reputation: 31

sudo pip install XlsxWriter

Make sure that X and W are in uppercase.

Upvotes: 3

skadaver
skadaver

Reputation: 103

I found the same error when using xlsxwriter in my test.py application. First, check if you have xlsxwriter module installed or not.

sudo pip install xlsxwriter

Then check the python version you are using, The following worked for me

python2 test.py

Upvotes: 0

soBusted
soBusted

Reputation: 305

I installed it by using a wheel file that can be found at this location: https://pypi.org/project/XlsxWriter/#files

I then ran pip install "XlsxWriter-1.2.8-py2.py3-none-any.whl"

Processing ./XlsxWriter-1.2.8-py2.py3-none-any.whl
Installing collected packages: XlsxWriter
Successfully installed XlsxWriter-1.2.8

Upvotes: 1

Liam Humphreys
Liam Humphreys

Reputation: 51

I managed to resolve this issue as follows...

Be careful, make sure you understand the IDE you're using! - Because I didn't. I was trying to import xlsxwriter using PyCharm and was returning this error.

Assuming you have already attempted the pip installation (sudo pip install xlsxwriter) via your cmd prompt, try using another IDE e.g. Geany - & import xlsxwriter.

I tried this and Geany was importing the library fine. I opened PyCharm and navigated to 'File>Settings>Project:>Project Interpreter' xlslwriter was listed though intriguingly I couldn't import it! I double clicked xlsxwriter and hit 'install Package'... And thats it! It worked!

Hope this helps...

Upvotes: 5

Thomas meriaux
Thomas meriaux

Reputation: 87

I am not sure what caused this but it went all well once I changed the path name from Lib into lib and I was finally able to make it work.

Upvotes: 1

byteC0de
byteC0de

Reputation: 5273

Here are some easy way to get you up and running with the XlsxWriter module.The first step is to install the XlsxWriter module.The pip installer is the preferred method for installing Python modules from PyPI, the Python Package Index:

sudo pip install xlsxwriter

Note

Windows users can omit sudo at the start of the command.

Upvotes: 58

user5267119
user5267119

Reputation: 151

I have the same issue. It seems that pip is the problem. Try

pip uninstall xlsxwriter
easy_install xlsxwriter

Upvotes: 15

Related Questions