Home > Software design >  ImportError: No module named openpyxl
ImportError: No module named openpyxl

Time:11-24

I installed openpyxl via pip3 but whenever I try to import it into my script I get this error:

"python -u "/Users/hectorv/zipcodes/zips.py"
hectorv@Hectors-MacBook-Air zipcodes % python -u "/Users/hectorv/zipcodes/zips.py"
Traceback (most recent call last):
  File "/Users/hectorv/zipcodes/zips.py", line 1, in <module>
    import openpyxl
ImportError: No module named openpyxl"

When I try to install again I get this:

hectorv@Hectors-MacBook-Air zipcodes % pip3 install openpyxl
Requirement already satisfied: openpyxl in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.0.9)
Requirement already satisfied: et-xmlfile in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from openpyxl) (1.1.0)

CodePudding user response:

You are using Code Runner, isn't it?

You can avoid using the Code Runner. After you selected the proper python interpreter, you can click the Run Python File button, or right-click and select Run Python File In Terminal command.

enter image description here

enter image description here

enter image description here

If you insist on using the Code Runner, you can add "code-runner.runInTerminal": true, in the settings.json file. This is because if you run the Code Runner directly in the OUTPUT panel, it will take advantage of the global python, ignoring the python interpreter selected by the Python extension.

  • Related