Python 导入错误:没有名为“加密”的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28355385/
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 03:08:54  来源:igfitidea点击:

ImportError: No module named 'Crypto'

pythonimporterrorpycrypto

提问by crobject

I am working with pycrypto. It works fine on my local windows machine, but when I move it to my python box I get an error with importing the module:

我正在使用 pycrypto。它在我的本地 Windows 机器上运行良好,但是当我将它移动到我的 python 框时,我在导入模块时出现错误:

from Crypto.Cipher import ARC4 
ImportError: No module named 'Crypto'

The output of python3.3 -c "from Crypto.Cipher import ARC4"

的输出 python3.3 -c "from Crypto.Cipher import ARC4"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'Crypto'

output of pip3 list has a reference includes pycrypto (2.6.1)

pip3 列表的输出有一个参考,包括 pycrypto (2.6.1)

I know it works with Python 2.7.6, but I wrote the script in 3.3 so it depends on some things from 3.3

我知道它适用于 Python 2.7.6,但我在 3.3 中编写了脚本,因此它取决于 3.3 中的某些内容

采纳答案by IronManMark20

I am assuming that your "python box" is a remote computer.

我假设您的“python box”是一台远程计算机。

First, make sure pycrypto is up to date (pip3 install --upgrade pycrypto). The older versions may not be compatible with python 3.3

首先,确保 pycrypto 是最新的 ( pip3 install --upgrade pycrypto)。旧版本可能与 python 3.3 不兼容

If that doesn't work, try looking in site-packages (the directory) to make sure the functions actually exist.

如果这不起作用,请尝试查看站点包(目录)以确保这些功能确实存在。

If none of that works, it might be easier (just a suggestion) to use from future importthe things you need. That way it is python 2&3 compatible.

如果这些都不起作用,那么使用from future import您需要的东西可能会更容易(只是一个建议)。这样它就与python 2&3兼容。

回答by winklerrr

As I already wrote in this answer:

正如我在这个答案中已经写的那样:

WARNING: Don't use pycryptoanymore!

警告:不要再使用pycrypto了!

Use pycryptodomeinstead, via pip3 install pycryptodome.

pycryptodome改为使用,通过pip3 install pycryptodome

But make sure that you don't have pycryptoinstalled, because both packages install under the same folder Crypto.

但是请确保您没有pycrypto安装,因为两个软件包都安装在同一个文件夹下Crypto