Modulenotfounderror: no module named openpyxl ( Solved )

Modulenotfounderror_ no module named openpyxl ( Solved )

Modulenotfounderror: no module named openpyxl error occurs when openpyxl module is either not installed or misconfigured with the system path. There are many situations where we install openpyxl in any virtual environment but run the application or code base in a different virtual environment or globally.  Since the installed openpyxl is pointed with a different interpreter and not available in any other virtual environment. This time the currently selected interpreter will throw the same error.  Anyways In this article, How can we install openpyxl differently and fix this modulenotfounderror.

modulenotfounderror: no module named openpyxl ( Solution ) –

We will install this openpyxl module with pip, conda, and source code. In each section, we will also try to cover the variation.

Method 1: pip for installation openpyxl –

Use this command to install openpyxl.

pip install openpyxl

We can specify the version detail along with the command to avoid compatibility issues if any with the latest version. Since the above one will install the latest stable version of openpyxl.

pip install openpyxl==3.0.9

You have to also check the version of python before using the pip or pip3 command. If the version is 3.xx then use pip3 command and if it 2.xx then use pip command.

If Admin privileges are required to run this command in Linux or a similar OS then add sudo keyword along with it. Also if you are on Windows-based OS then launch the cmd in admin mode and rerun the above command.

Modulenotfounderror no module named openpyxl using pip
Modulenotfounderror no module named openpyxl using pip

 

Method 2: conda for installation openpyxl –

If you have Anaconda installed in the system and you want to use conda ( default package manager ) then use the below command to install openpyxl.

conda install -c anaconda openpyxl
No module named openpyxl using conda
No module named openpyxl using conda

Method 3: Installation through source code –

In this step, we will first download the source code for openpyxl implementation in Python. Now we need to run –

python setup.py install

It will build the file locally and then we have to place it into site-packages folder before we import the package. It will fix the above error.

Thanks
Data Science Learner Team

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Meet Abhishek ( Chief Editor) , a data scientist with major expertise in NLP and Text Analytics. He has worked on various projects involving text data and have been able to achieve great results. He is currently manages Datasciencelearner.com, where he and his team share knowledge and help others learn more about data science.
 
Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner