Home > OS >  No Module found named 'XlsxWriter' python3 VScode
No Module found named 'XlsxWriter' python3 VScode

Time:10-15

having an issue with importing modules and them not being recognized in VSCode

Here is my code:

import pandas as pd
import XlsxWriter

#Import excel file
dataframe = pd.read_excel(r'C:\Users\ntanner\Downloads\trial-excel.xlsx',sheet_name = 'Chemical Audit Log', index = False)

dataframe2 = pd.read_excel(r'C:\Users\ntanner\Downloads\trial-excel.xlsx',sheet_name = 'Defect Chemical Log', index = False)

#display the data frame
dataframe

When I run this from command prompt, as I am on windows, I use the following command: C:\Users\MYNAME\Documents\Coding\xlsx practice>python test.py here is the result:

PS C:\Users\MYNAME\Documents\Coding\xlsx practice> python .\test.py
Traceback (most recent call last):
  File "C:\Users\MYNAME\Documents\Coding\xlsx practice\test.py", line 6, in <module>
    dataframe = pd.read_excel(r'C:/Users/ntanner\Downloads/trial-excel.xlsx',sheet_name = 'Chemical Audit Log', index = False)
  File "C:\Users\MYNAME\AppData\Roaming\Python\Python310\site-packages\pandas\util\_decorators.py", line 211, in wrapper     
    return func(*args, **kwargs)
  File "C:\Users\MYNAME\AppData\Roaming\Python\Python310\site-packages\pandas\util\_decorators.py", line 317, in wrapper     
    return func(*args, **kwargs)
TypeError: read_excel() got an unexpected keyword argument 'index'
PS C:\Users\MYNAME\Documents\Coding\xlsx practice> 

In VS Code, I have tried running the program on every interpreter using the built in terminal. I am not entirely sure what the differences of them are, regardless, I get the same result as when I run it from command prompt. I have installed and uninstalled the xlsxwriter using pip install xlsx multiple times and I get the result:

Requirement already satisfied: xlsxwriter in c:\python310\lib\site-packages (3.0.3)

I have verified that xlsxwriter is inside of C:\Python310\Lib\site-packages.

Any ideas? If you need more info I can provide it.

CodePudding user response:

A No module error usually means the library is installed. You can try a

pip install XlsxWriter

CodePudding user response:

The error message shown in the the traceback about an unexpected keyword argument is not the same as the error in the title about not having xlsxwriter installed.

The traceback error message is saying that pandas read_excel() doesn't have a parameter called index, which you have added in your code.

  • Related