No module named openpyxl - Python 3.6 - OSX

15,503

Try to do:

pip3 install --user openpyxl

Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.

Share:
15,503

Related videos on Youtube

Will
Author by

Will

Updated on June 04, 2022

Comments

  • Will
    Will almost 2 years

    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?

    • Azat Ibrakov
      Azat Ibrakov almost 7 years
      try to print out python3.4 -m pip freeze
    • Azat Ibrakov
      Azat Ibrakov almost 7 years
      and see if there is what are you looking for
    • Tiny.D
      Tiny.D almost 7 years
      did you run your test.py with python2?
    • Azat Ibrakov
      Azat Ibrakov almost 7 years
      @Will: yeap, you should
    • Will
      Will almost 7 years
      @Tiny.D: I'm not sure...the build system in Sublime is just set to "Python." How can I find out if this is really Python2?
    • Tiny.D
      Tiny.D almost 7 years
      @Will check your python version first, then refer to this answer stackoverflow.com/questions/23161604/…
    • Will
      Will almost 7 years
      @Tiny.D: that must be it. ST is reporting version 2.7 so I need to force it to use 3.6 instead. Thanks for the link!
    • Tiny.D
      Tiny.D almost 7 years
      @Will great, glad you find the right solution :)
    • Azat Ibrakov
      Azat Ibrakov almost 7 years
      @Tiny.D: you should probably write an answer or it may be OP
    • Tiny.D
      Tiny.D almost 7 years
      @AzatIbrakov thanks :) i think the links answer will provide all guidance.