'ImportError: Missing optional dependency 'openpyxl' still doesn't work after instllation

ubuntu 18.04, python3.8 and using pycharm.

Interpreter path in pychamr is correctly set.

while trying to read specific sheet in excel, using openpyxl it keeps on giving me ImportError. ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.

I've installed using pip3 install openpyxl and it say requirement is already satisfied. However when I run it again in pycharm it still outputs same error.

Requirement already satisfied: openpyxl mycomp/.local/lib/python3.8/site-packages (3.0.7)
Requirement already satisfied: et-xmlfile in mycomp/.local/lib/python3.8/site-packages (from openpyxl) (1.0.1)

My guess is since I am using venv it is not getting installed correctly in venv because when I look at the path upon install it is not where venv is.

When I do pip3 freeze on venv and after deactivating venv it looks like it has same installation.



Solution 1:[1]

for me worked typing the following inside an interactive session:

import pip
pip.main(["install", "openpyxl"])

Solution 2:[2]

Deleting venv and creating a new one fixed the issue.

previous venv had all dependencies as base which did not make sense. Maybe error on venv? I am curious to know if anyone knows.

Solution 3:[3]

What helped in my case: installing an additional optional library

pip install defusedxml

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jamesB
Solution 2 haneulkim
Solution 3 Holger Nösekabel