[Solved] No module named ‘openpyxl’ – Python 3.4 – Ubuntu

I installed openpyxl with

$ pip install openpyxl

when I try the command

from openpyxl import Workbook

I get

Traceback (most recent call last):
 File "<pyshell#0>", line 1, in <module>
from openpyxl import Workbook
ImportError: No module named 'openpyxl'

I am using Python 3.4 and Ubuntu 14.04, 32-bit OS type

Solution #1:

@zetysz and @Manish already fixed the problem. I am just putting this in an answer for future reference:

  • pip refers to Python 2 as a default in Ubuntu, this means that pip install x will install the module for Python 2 and not for 3

  • pip3 refers to Python 3, it will install the module for Python 3

Respondent: Caridorc

Solution #2:

In order to keep track of dependency issues, I like to use the conda installer, which simply boils down to:

conda install openpyxl
Respondent: Archie

Solution #3:

If you don’t use conda, just use :

pip install openpyxl

If you use conda, I’d recommend :

conda install -c anaconda openpyxl

instead of simply conda install openpyxl

Because there are issues right now with conda updating (see GitHub Issue #8842) ; this is being fixed and it should work again after the next release (conda 4.7.6)

Respondent: ToddEmon

Solution #4:

You have to install it explixitly using the python package manager as

  1. pip install openpyxl for Python 2
  2. pip3 install openpyxl for Python 3
Respondent: utkarshh12

Solution #5:

If you’re using Python3, then install:

python3 -m pip install --user xlsxwriter

This will run pip with the appropriate version of Python3. If you run bare pip3 and have many versions of Python install, it will still fail leading to more confusion.

The –user flag will allow to install as a regular user and no require root.

Respondent: reisy

Solution #6:

I had the same problem solved using instead of pip install :

sudo apt-get install python-openpyxl
sudo apt-get install python3-openpyxl

The sudo command also works better for other packages.

Respondent: rainer

Solution #7:

I still was not able to import ‘openpyxl’ after successfully installing it via both conda and pip. I discovered that it was installed in ‘/usr/lib/python3/dist-packages’, so this worked for me:

import sys 

Hope this might be useful for others.

Respondent: ConZZito

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy