No module named openpyxl - Python 3.6 - OSX

Viewed 15945

I've installed openpyxl from the Terminal using

pip3 install openpyxl

without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.

The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:

Traceback (most recent call last): File "/Users/wcw/Desktop/test.py", line 1, in import openpyxl ImportError: No module named openpyxl

How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?

3 Answers

I have the same problem.

I've installed the openpyxl succesfully via Anaconda

!pip3 install --upgrade openpyxl

Collecting openpyxl Using cached https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz Requirement already satisfied, skipping upgrade: jdcal in /Users/a18301335/Library/Python/3.8/lib/python/site-packages (from openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade: et_xmlfile in /Users/a18301335/Library/Python/3.8/lib/python/site-packages (from openpyxl) (1.0.1) Installing collected packages: openpyxl Found existing installation: openpyxl 1.8.6 Uninstalling openpyxl-1.8.6: Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3

But when I try to use tat library I get an error No module named openpyxl

import openpyxl

ModuleNotFoundError: No module named 'openpyxl'

If I try to import openpyxl in Terminal, I don't have the error. What's wrong?

This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.

Related