No module named 'openpyxl' - Python 3.4 -

2019-02-21 15:05发布

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

4条回答
Lonely孤独者°
2楼-- · 2019-02-21 15:42

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
查看更多
我只想做你的唯一
3楼-- · 2019-02-21 15:52

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.

查看更多
放我归山
4楼-- · 2019-02-21 15:54

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

conda install openpyxl
查看更多
▲ chillily
5楼-- · 2019-02-21 15:55

@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

查看更多
登录 后发表回答