No module named 'openpyxl' - Python 3.4 - Ubuntu

我与影子孤独终老i 提交于 2019-12-18 18:55:09

问题


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


回答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




回答2:


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

conda install openpyxl



回答3:


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



回答4:


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)




回答5:


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.




回答6:


If you're using python3, then install:

sudo pip3 install xlsxwriter


来源:https://stackoverflow.com/questions/34509198/no-module-named-openpyxl-python-3-4-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!