没有名为“openpyxl”的模块 - Python 3.4 - Ubuntu

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34509198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:06:27  来源:igfitidea点击:

No module named 'openpyxl' - Python 3.4 - Ubuntu

pythonubuntupython-3.4openpyxl

提问by FrancescoVe

I installed openpyxlwith

我安装openpyxl

$ 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

我使用的是 Python 3.4 和 Ubuntu 14.04,32 位操作系统类型

采纳答案by Caridorc

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

@zetysz 和 @Manish 已经解决了这个问题。我只是把它放在一个答案中以备将来参考:

  • piprefers to Python 2as a defaultin Ubuntu, this means that pip install xwill install the module for Python 2and not for 3

  • pip3refers to Python 3, it will install the module for Python 3

  • pip将 Python 2称为Ubuntu 中的默认值,这意味着pip install x将为 Python 2不是 3安装模块

  • pip3指的是 Python 3,它将安装 Python 3的模块

回答by rainer

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

我使用代替 pip install 解决了同样的问题:

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

The sudo command also works better for other packages.

sudo 命令也适用于其他软件包。

回答by Archie

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

为了跟踪依赖性问题,我喜欢使用conda installer,它简单地归结为:

conda install openpyxl

回答by utkarshh12

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

您必须使用 python 包管理器 explixitly 安装它

  1. pip install openpyxl for Python 2
  2. pip3 install openpyxl for Python 3
  1. pip install openpyxl for Python 2
  2. pip3 为 Python 3 安装 openpyxl

回答by ToddEmon

If you don't use conda, just use :

如果您不使用 conda,只需使用:

pip install openpyxl

If you use conda, I'd recommend :

如果您使用 conda,我建议:

conda install -c anaconda openpyxl

instead of simply conda install openpyxl

而不是简单地 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)

因为现在 conda 更新存在问题(请参阅GitHub 问题 #8842);这正在修复中,它应该在下一个版本后再次工作(conda 4.7.6)

回答by reisy

If you're using python3, then install:

如果您使用的是 python3,请安装:

sudo pip3 install xlsxwriter