Python installs Crypto library error (from Crypto.Cipher import AES ModuleNotFoundError: No module named 'Crypto')

Python installs the Crypto library and reports an error

The tutorials searched on the Internet use third-party libraries 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:

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

insert image description here

1. Online solutions

So I found a solution on the Internet:
Most of the tutorials on the Internet said to uninstall Crypto and pycrypto libraries first
, but pycrypto is not installed, so there is no uninstallation.
insert image description here

1. Uninstall Crypto and pycrypto libraries

Uninstall Crypto and pycrypto library command

pip uninstall Crypto
pip uninstall pycrypto

2. Install the pycryptodome library

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

pip install pycryptodome

Let me talk about the relationship between these three libraries:
crypto, pycrypto, and pycryptodome are one thing. The name of crypto on python is pycrypto. It is a third-party library and has been stopped. I understand that pycryptodome is the first two. updated version.

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

Note: When installing pycryptodome, the Crypto file will appear in the Python library file.
Still not working with this solution.

2. Another solution

Later, I groped for what was going on, and there was no problem during the installation process.

In the project creation interface, I found that a checkmark related to the third-party library was not checked. After checking it, no more errors were reported.

The specific meaning is to copy a copy of the global package to the virtual environment, which is convenient for later project management and release. It is recommended to check it.
insert image description here
Then tick it, and the problem is solved! If the error is still reported, it may be another problem.

Guess you like

Origin blog.csdn.net/qq_43589852/article/details/125928232