News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

2024-11(5)

Python installs Crypto library and reports an error: ModuleNotFoundError: No module named 'Crypto'

posted on 2024-11-02 14:29     read(813)     comment(0)     like(9)     collect(3)


Table of contents

from Crypto.Cipher import AES

1. Solution

1. Uninstall Crypto and pycrypto libraries

2. Install the pycryptodome library

2. Another solution (I saw other people's problems, but I didn't encounter this situation)


 

from Crypto.Cipher import AES

The tutorial I searched online uses a third-party library to implement the AES algorithm . (The tutorial is linked here:  Python implements AES encryption and decryption )

The first step is to install the pycryptodome module

After installing this module, an error is reported.
The specific error content is as follows:

  1. Traceback (most recent call last):
  2. File "E:\pythonProject\0000.py", line 1, in <module>
  3. from Crypto.Cipher import AES
  4. ModuleNotFoundError: No module named 'Crypto'

1. Solution

Many people may install Crypto using pip install which is incorrect for this library.

Need to install

pip install pycryptodome

If you have already installed the above pip install Crypto, you need to uninstall this library. Similarly, if you have installed other libraries from other posts, you need to uninstall them.

Then pip install pycryptodome

That is:

1. Uninstall Crypto and pycrypto libraries

Uninstall Crypto and pycrypto library commands

  1. pip uninstall Crypto
  2. pip uninstall pycrypto
2. Install the pycryptodome library

Next, install the third-party library pycryptodome (it seems to require Python3m)

 

pip install pycryptodome

Let's talk about the relationship between these three libraries:
crypto, pycrypto and pycrytodome are the same thing. The name of crypto in python is pycrypto. It is a third-party library and has stopped updating. What I understand is that pycrytodome is an upgraded version of the previous two.

Therefore, if you need the Crypto library, just use the command pip install pycryptodome

Note: When installing pycryptodome, this Crypto file will appear in the Python library file.
This solution still does not work.

 

2. Another solution (I saw other people's problems, but I didn't encounter this situation)

In the project creation interface, I found that a check mark related to the third-party library was not checked. After checking it, there was no error.

The specific meaning is to copy a copy of the global package to the virtual environment to facilitate later project management and release. It is recommended to check it.

 

 Then check it and the problem will be solved! If the error still occurs, it may be another problem.



Category of website: technical article > Blog

Author:Disheartened

link:http://www.pythonblackhole.com/blog/article/245815/98bb847bef4314b0dc37/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

9 0
collect article
collected

Comment content: (supports up to 255 characters)