Python 没有名为 crypto.cipher 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31485110/
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
no module named crypto.cipher
提问by Arion_Miles
I'm trying my hands on encryption for a while now. I recently got hands on this python based crypter named PythonCrypter.
我正在尝试加密一段时间。我最近接触了这个名为PythonCrypter 的基于 python 的加密器。
I'm fairly new to Python and when I try to open the CodeSection.py file via terminal, I get error saying from Crypto.Cipher import AES
ImportError: No Module Named Crypto.Cipher
我对 Python 还很陌生,当我尝试通过终端打开 CodeSection.py 文件时,出现错误提示 from Crypto.Cipher import AES
ImportError: No Module Named Crypto.Cipher
What am I doing wrong?
我究竟做错了什么?
回答by omri_saadon
In order to use the pycypto library you should install it with:
为了使用 pycypto 库,您应该安装它:
pip install pycrypto
or
或者
easy_install pycrypto
回答by johnny_be
PyCrypto doesn't play well with Windows systems if you're installing using pip or easy_install... or at least it didn't for me.
如果您使用 pip 或 easy_install 安装,PyCrypto 不能很好地与 Windows 系统配合使用……或者至少它不适合我。
Try using the prebuilt binaries for Windows here: http://www.voidspace.org.uk/python/modules.shtml#pycrypto
尝试在此处使用适用于 Windows 的预构建二进制文件:http: //www.voidspace.org.uk/python/modules.shtml#pycrypto
回答by thephez
I just encountered this issue with Python 2.7 on Windows. My solution was to rename the folder from ..\site-packages\crypto to ..\site-packages\Crypto. The lower case "c" was causing the import error.
我刚刚在 Windows 上使用 Python 2.7 遇到了这个问题。我的解决方案是将文件夹从 ..\site-packages\ crypto重命名为 ..\site-packages\ Crypto。小写“c”导致导入错误。
See https://github.com/pypa/pip/issues/3309for details.
有关详细信息,请参阅https://github.com/pypa/pip/issues/3309。
回答by bin456789
pip uninstall Crypto
pip uninstall pycrypto
pip install pycrypto
That works for me.
这对我行得通。
The point is, when you install pycrypto
, you should remove Crypto
first
关键是,当你安装时pycrypto
,你应该Crypto
先删除
回答by Hitechcomputergeek
I just spent half an hour figuring this out on Ubuntu. Turns out, I had installed the python-pycryptopp
package through apt (I prefer to avoid pip if possible), but the package I needed was actually python-crypto
.
我只花了半个小时在 Ubuntu 上解决了这个问题。事实证明,我已经python-pycryptopp
通过 apt安装了该软件包(如果可能,我更愿意避免使用 pip),但我需要的软件包实际上是python-crypto
.
回答by pri
I think u should try this:
我想你应该试试这个:
sudo pip2 install pycrypto
回答by deepak
In ubuntu 18.04.2 LTS installing pycryptodome package resolved the issue
在 ubuntu 18.04.2 LTS 安装 pycryptodome 包解决了这个问题
回答by Amin
In my case, pycrypto package was not installed, when I tried to add it: I ran into the following error which was rectified by downloading and installing C++ Compiler for Python 2.7.
在我的情况下,pycrypto 包没有安装,当我尝试添加它时:我遇到了以下错误,该错误已通过下载和安装C++ Compiler for Python 2.7得到纠正。
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
错误:需要 Microsoft Visual C++ 9.0。从http://aka.ms/vcpython27获取它
回答by mhegglin
I know this has already been answered, but I want to expand a little bit
我知道这已经得到了回答,但我想扩展一点
pip install Crypto --> IS THE WRONG PACKAGE
if you do this run the below to remove it:
如果您这样做,请运行以下命令将其删除:
$> pip uninstall Crypto
Now, to install type:
现在,安装类型:
$> pip uninstall pycrypto --> just in case you have a broken package already
$> pip install pycrypto
On macOS Catalinathis will automatically install the pycryptopackage for Python3.6ONLY.
在macOS Catalina 上,这将自动安装仅适用于Python3.6的pycrypto包。
This means that if you run:
这意味着如果你运行:
python your_script.py
It wil fail. Unless of course Python3is set as your default.
它会失败。当然,除非Python3被设置为默认值。
Now if you really want to run pycryptoon Python2you can run the below
现在如果你真的想在Python2上运行pycrypto你可以运行下面的
$> sudo pip2 install pycrypto
You will need the sudo for this to work!
您将需要 sudo 才能正常工作!
This will install pycryptofor Python2only.
这将安装pycrypto为Python2只。
I hope this helps someone who might be installing then running with python2, or who wants the package installed with Python2but is continuously installing with the Python3package
我希望这可以帮助那些可能正在安装然后使用 python2 运行的人,或者谁想要使用Python2安装软件包但继续使用Python3软件包安装的人