No module named 'openpyxl'

53 views
Skip to first unread message

Rahul Pandey

unread,
Jan 13, 2023, 5:45:12 AMJan 13
to openpyxl-users
ae2018 = pd.read_excel(r'2018 AE Summary.xlsx',sheet_name='2018 AE')
This line of code was run in Jyputer notebook, and it gave the following error:

Output exceeds the size limit. Open the full output data in a text editor
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) File c:\Users\ankit\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\compat\_optional.py:138, in import_optional_dependency(name, extra, errors, min_version) 137 try: --> 138 module = importlib.import_module(name) 139 except ImportError: File c:\Users\ankit\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py:126, in import_module(name, package) 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level) File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level) File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_) File <frozen importlib._bootstrap>:1004, in _find_and_load_unlocked(name, import_) ModuleNotFoundError: No module named 'openpyxl' During handling of the above exception, another exception occurred: ImportError Traceback (most recent call last) Cell In [19], line 1 ----> 1 ae2018 = pd.read_excel(r'2018 AE Summary.xlsx',sheet_name='2018 AE')
...
--> 141 raise ImportError(msg) 142 else: 143 return None ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.

After receiving this message, I have installed openpyxl in the project environment, but it gives the same error.  I don't know why this error persists even though I am not using openpyxl library to read the .xlsl file. Can anyone kindly let me know what the issue maybe?
openpyxl.PNG

Felipe Dante

unread,
Jan 13, 2023, 7:34:45 AMJan 13
to openpyxl-users
I have the same problem

Charlie Clark

unread,
Jan 13, 2023, 8:00:40 AMJan 13
to 'Rahul Pandey' via openpyxl-users
On 13 Jan 2023, at 11:45, 'Rahul Pandey' via openpyxl-users wrote:

> After receiving this message, I have installed openpyxl in the project
>
> environment, but it gives the same error. I don't know why this error
>
> persists even though I am not using openpyxl library to read the .xlsl
>
> file. Can anyone kindly let me know what the issue maybe?

You obviously haven't succeeded in installing openpyxl for the project. Check sys.path for information and then your Jupyter docs.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Rahul Pandey

unread,
Jan 13, 2023, 8:02:26 AMJan 13
to openpyxl-users
I have fixed this issue, by installing openpyxl in the same environment I am working with the project, in my case as i was using Jyupter notebook, i installed the library in notebook cell using pip install openpyxl, insted of the terminal. It works but gives a warning, which for me can be ignored for the time being. I used pandas, therefor in the engine arg, i speciifed engine = 'openpyxl'. Make sure the package is corrected installed in the right environment.

Regards,

Rahul Pandey

unread,
Jan 13, 2023, 8:06:43 AMJan 13
to openpyxl-users
I have solved the issue but this message appears :

c:\Users\ankit\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\worksheet\_reader.py:312: UserWarning: Unknown extension is not supported and will be removed warn(msg)

Is there a solution to this apart from  forcing to ignore the warning.

Regards,

Charlie Clark

unread,
Jan 13, 2023, 8:12:22 AMJan 13
to 'Rahul Pandey' via openpyxl-users
On 13 Jan 2023, at 14:06, 'Rahul Pandey' via openpyxl-users wrote:

> I have solved the issue but this message appears :
>
> c:\Users\ankit\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\worksheet\_reader.py:312:
>
> UserWarning: Unknown extension is not supported and will be removed
>
> warn(msg)
>
> Is there a solution to this apart from forcing to ignore the warning.

This is not an error but an informative warning letting you know that some parts of the workbook will be lost. As such no solution is required. It's up to you if you want to disable warnings.
Reply all
Reply to author
Forward
0 new messages