No module named crypto python windows

no module named crypto.cipher

I’m trying my hands on encryption for a while now. I recently got hands on this python based crypter named PythonCrypter.

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

What am I doing wrong?

9 Answers 9

That works for me.

The point is, when you install pycrypto , you should remove Crypto first

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.

In order to use the pycypto library you should install it with:

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.

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 .

In ubuntu 18.04.2 LTS installing pycryptodome package resolved the issue

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.

error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

I think u should try this:

I know this has already been answered, but I want to expand a little bit

if you do this run the below to remove it:

Now, to install type:

On macOS Catalina this will automatically install the pycrypto package for Python3.6 ONLY.

This means that if you run:

It wil fail. Unless of course Python3 is set as your default.

Now if you really want to run pycrypto on Python2 you can run the below

You will need the sudo for this to work!

This will install pycrypto for Python2 only.

I hope this helps someone who might be installing then running with python2, or who wants the package installed with Python2 but is continuously installing with the Python3 package

ImportError: No module named Crypto.Cipher

When I try to run app.py (Python 3.3, PyCrypto 2.6) my virtualenv keeps returning the error listed above. My import statement is just from Crypto.Cipher import AES . I looked for duplicates and you might say that there are some, but I tried the solutions (although most are not even solutions) and nothing worked.

Читайте также:  Windows 10 edge reinstall

You can see what the files are like for PyCrypto below:

27 Answers 27

I had the same problem (though on Linux). The solution was quite simple — add:

to my app.yaml file. Since this worked correctly in the past, I assume this is a new requirement.

I had the same problem on my Mac when installing with pip . I then removed pycrypto and installed it again with easy_install , like this:

also as Luke commented: If you have trouble running these commands, be sure to run them as admin (sudo)

Hope this helps!

EDIT: As winklerr correctly notes above, pycrypto is no longer safe. Use pycryptodome instead, it is a drop-in replacement

I ran into this on Mac as well, and it seems to be related to having an unfortunately similarly named «crypto» module (not sure what that is for) installed alongside of pycrypto via pip.

The fix seems to be removing both crypto and pycrypto with pip:

and reinstalling pycrypto:

Now it works as expected when I do something like:

WARNING: Don’t use crypto or pycrypto anymore!

As you can read on this page, the usage of pycrypto is not safe anymore:

Pycrypto is vulnerable to a heap-based buffer overflow in the ALGnew function in block_templace.c. It allows remote attackers to execute arbitrary code in the python application. It was assigned the CVE-2013-7459 number.

Pycrypto didn’t release any fix to that vulnerability and no commit was made to the project since Jun 20, 2014.

Update 2021-01-18: The CVE is fixed now (thanks @SumitBadsara for pointing it out!). You can find the current status of the open security tickets for each package at the Debian security tracker:

Use Python3’s pycryptodome instead!

Make sure to uninstall all versions of crypto and pycrypto first, then install pycryptodome :

All of these three packages get installed to the same folder, named Crypto . Installing different packages under the same folder name can be a common source for errors!

Best practice: virtual environments

In order to avoid problems with pip packages in different versions or packages that install under the same folder (i.e. pycrypto and pycryptodome ) you can make use of a so called virtual environment. There, the installed pip packages can be managed for every single project individually.

To install a virtual environment and setup everything, use the following commands:

Python Tests: No module named ‘Crypto’ #1137

Comments

nibanks commented Jan 12, 2017

I am working on getting the Python tests running on Windows again, since the dependency on the sniffer interface was added. I am coming across a dependency I am lacking but I don’t know where/how to install it. Any help would be appreciated.

The text was updated successfully, but these errors were encountered:

jwhui commented Jan 12, 2017

The package you need is pycryptodome version 3.4.3. You can install it via the following command.

I ran into this issue as part of #985. I agree this should be included in a README or doc somewhere.

For future reference, viewing the Travis before_install.sh script is also helpful.

nibanks commented Jan 12, 2017

Thanks. That seemed to work!

zsolthajnal commented Jan 26, 2018

Thanks as well. This worked to me too.

Macielyoung commented Apr 9, 2018

Thanks. I have tried various methods and they didn’t work to me. Your method works well.

guanhui07 commented Jul 3, 2018

` from Crypto.Hash import HMAC
ModuleNotFoundError: No module named ‘Crypto’
(venv)

guanhui07 at sily in /data1/work/weikang/python/ggtc-api on git:master x [10:24:30] C:1

-> pip list | grep crypt
DEPRECATION: The default format will switch to columns in the future. You can use —format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
asn1crypto (0.24.0)
crypto (1.4.1)
cryptography (2.2.2)
pycrypto (2.6.1)
pycryptodome (3.4.3)
`

Читайте также:  Удалить загрузку windows при включении

I have uninstall and install , and can see package in pip list but it still out errors ModuleNotFoundError: No module named ‘Crypto’

jwhui commented Jul 3, 2018 •

@guanhui07, uninstall pycrypto . There is name collision in packages pycrypto and pycryptodome (both have module Crypto ).

cisordeng commented Aug 8, 2018

PandaTea commented Nov 3, 2018

sreeramp96 commented May 9, 2019 •

from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named ‘Crypto’
I have installed Crypto using pip, but still it shows this error

HarshdipD commented Sep 14, 2019

I’m getting the same error, and I have pycrpytodome installed version 3.9.0

jwhui commented Sep 17, 2019

@HarshdipD, did you uninstall pycrypto ?

If so, can you provide the output of pip list | grep crypt ?

HarshdipD commented Sep 17, 2019

@jwhui I did not have pycrypto installed. My issue was solved by changing folder name from crypto to Crypto . Thank you!

blackfur commented Oct 12, 2019

Have you solve this? I have this error too.

saikiran994 commented Oct 27, 2019

even i am also facing same problem

bukepo commented Oct 27, 2019

@blackfur @saikiran994 Could you try pip3 install -r tests/scripts/thread-cert/requirements.txt ?

jwhui commented Oct 28, 2019

@saikiran994, have you tried the proposed resolutions above?

jwhui commented Oct 29, 2019

  1. pycrypto is not installed
  2. pycryptodome is installed

If that does not help, can you provide the output of pip3 list | grep crypt ?

joseph-dougal commented Oct 31, 2019 •

@saikiran994 Had the same issue on Win10.

Rename the folder in site-packages from crypto to Crypto.

4tal commented Nov 19, 2019

Rename the folder in site-packages from crypto to Crypto.

Help me as well on Mac

68jai90 commented Apr 2, 2020

@jwhui I did not have pycrypto installed. My issue was solved by changing folder name from crypto to Crypto . Thank you!

This worked for me to

simonlingoogle commented Apr 3, 2020

@jwhui I did not have pycrypto installed. My issue was solved by changing folder name from crypto to Crypto . Thank you!

This worked for me to

If this is the solution, maybe we should try import both Crypto and crypto and choose whichever works?

2s5a3i8d commented Apr 17, 2020

I have the same problem. I have installed python via anaconda. Where can I change folder name from crypto to Crypto?

InstaAds commented May 17, 2020

Ok i found solution for this
first of all use command >>pip uninstall crypto
then >> pip uninstall pycryptodome
then >> pip install pycryptodome

Mariiooo commented May 26, 2020

Yo, I have this problem now with in our Python application.
We are using Crypto. On my friends MAC it’s working. But when I open the code on WINDOWS I’m getting an error.

from Crypto.Cipher import AES
ModuleNotFoundError: No module named ‘Crypto’

This is my Pip List.
Package Version

certifi 2020.4.5.1
chardet 3.0.4
idna 2.9
Naked 0.1.31
pip 20.1.1
pycryptodome 3.9.7
PyYAML 5.3.1
requests 2.23.0
setuptools 41.2.0
shellescape 3.8.1
urllib3 1.25.9
wheel 0.34.2

What’s the problem and how can I solve it?

Mariiooo commented May 26, 2020 •

Try to change «Crypto» to «crypto». This is how is solved my issue.

On Tue, 26 May 2020, 19:40 Mariusz Blautzik, @.***> wrote: Yo, I have this problem now with in our Python application. We are using Crypto. On my friends MAC it’s working. But when I open the code on WINDOWS I’m getting an error. from Crypto.Cipher import AES ModuleNotFoundError: No module named ‘Crypto’ This is my Pip List. Package Version —————————— certifi 2020.4.5.1 chardet 3.0.4 idna 2.9 Naked 0.1.31 pip 20.1.1 pycryptodome 3.9.7 PyYAML 5.3.1 requests 2.23.0 setuptools 41.2.0 shellescape 3.8.1 urllib3 1.25.9 wheel 0.34.2 What’s the problem and how can I solve it? — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe https://github.com/notifications/unsubscribe-auth/AICMPTOWKGPXMRKSG2PZLMDRTOTB5ANCNFSM4C4H2ZBA .

Not working as well mate 🙁

Читайте также:  Видеодрайвер gigabyte для windows 10

If i change it to crypto it’s still giving error’s

Here is what i now have with the from Crypto.Cipher import AES

sameersam97 commented May 29, 2020

You just need to uninstall all your previous versions of crypto and pycryptodome and have a fresh installation of pycryptodome alone.

This works for me, Hope so it works for you as well 🙂

pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome

Try to change «Crypto» to «crypto». This is how is solved my issue.

On Tue, 26 May 2020, 19:40 Mariusz Blautzik, @.***> wrote: Yo, I have this problem now with in our Python application. We are using Crypto. On my friends MAC it’s working. But when I open the code on WINDOWS I’m getting an error. from Crypto.Cipher import AES ModuleNotFoundError: No module named ‘Crypto’ This is my Pip List. Package Version —————————— certifi 2020.4.5.1 chardet 3.0.4 idna 2.9 Naked 0.1.31 pip 20.1.1 pycryptodome 3.9.7 PyYAML 5.3.1 requests 2.23.0 setuptools 41.2.0 shellescape 3.8.1 urllib3 1.25.9 wheel 0.34.2 What’s the problem and how can I solve it? — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe https://github.com/notifications/unsubscribe-auth/AICMPTOWKGPXMRKSG2PZLMDRTOTB5ANCNFSM4C4H2ZBA .

Not working as well mate 🙁

If i change it to crypto it’s still giving error’s

Here is what i now have with the from Crypto.Cipher import AES

You just need to uninstall all your previous versions of crypto and pycryptodome and have a fresh installation of pycryptodome alone.

This works for me, Hope so it works for you as well 🙂

pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome

Mariiooo commented May 29, 2020

It has been fixed 🙂 Our pipeline docker container was not correctly set up. So that’s where the errors came from.

It had nothing to do with Crypto 😛

Basha963 commented Jun 2, 2020

You just need to uninstall all your previous versions of crypto and pycryptodome and have a fresh installation of pycryptodome alone.

This works for me, Hope so it works for you as well 🙂

pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome

Try to change «Crypto» to «crypto». This is how is solved my issue.

On Tue, 26 May 2020, 19:40 Mariusz Blautzik, @.***> wrote: Yo, I have this problem now with in our Python application. We are using Crypto. On my friends MAC it’s working. But when I open the code on WINDOWS I’m getting an error. from Crypto.Cipher import AES ModuleNotFoundError: No module named ‘Crypto’ This is my Pip List. Package Version —————————— certifi 2020.4.5.1 chardet 3.0.4 idna 2.9 Naked 0.1.31 pip 20.1.1 pycryptodome 3.9.7 PyYAML 5.3.1 requests 2.23.0 setuptools 41.2.0 shellescape 3.8.1 urllib3 1.25.9 wheel 0.34.2 What’s the problem and how can I solve it? — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe https://github.com/notifications/unsubscribe-auth/AICMPTOWKGPXMRKSG2PZLMDRTOTB5ANCNFSM4C4H2ZBA .

Not working as well mate 🙁
If i change it to crypto it’s still giving error’s

Here is what i now have with the from Crypto.Cipher import AES

You just need to uninstall all your previous versions of crypto and pycryptodome and have a fresh installation of pycryptodome alone.

This works for me, Hope so it works for you as well 🙂

pip uninstall crypto
pip uninstall pycryptodome
pip install pycryptodome

Оцените статью