Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 527
haneulkim Avatar asked Dec 12 '25 02:12

haneulkim


2 Answers

for me worked typing the following inside an interactive session:

import pip
pip.main(["install", "openpyxl"])
like image 123
jamesB Avatar answered Dec 15 '25 12:12

jamesB


I ran into something similar because pandas is using this behind the scenes.

Clean your local python environment or create a fresh virtual environment to use from your IDE. Then if possible, try installing your modules in one pip command instead of on multiple lines.

# THIS, substitute pandas for whatever module is using openpyxl
pip install pandas openpyxl

# NOT THIS
pip install pandas
pip install openpyxl

# VERSIONS
pandas==1.4.3
openpyxl==3.0.10
like image 40
edmonde Avatar answered Dec 15 '25 12:12

edmonde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!