Home > Backend Development > Python Tutorial > Detailed explanation of why python prompts ImportError: No module named Crypto when importing a module

Detailed explanation of why python prompts ImportError: No module named Crypto when importing a module

高洛峰
Release: 2017-03-15 14:21:58
Original
6383 people have browsed it

The beginning of the pit - the reason for the problem:
Running the python script, prompt:
ImportError: No module named Crypto
Reason: - - - Lack of crypto library (I imported the library through the pyCharm tool, but it was still unavailable, so I thought of importing it using the pip3 command line)
Start solving the pitfall:
The first step: check the information online, Need toinstallpython's pycrypto library
(1)Queryinstallation library, you need to install pip first
(2)The statement to install pip:
a, install pip: It is recommended to install Homebrew, and then brew install python

b to get home-brew: command line execution: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
c, the command line continues to execute: brew install wget
d, then check pip, it has been installed Successful
(3) After installing pip, since the default is python2.7 and currently using python3.6, you need to specify pip to install to python3.6
(4) Check the pip version on the command line. It has been It is 9.0.1
Information link: https://www.zhihu.com/question/50470150?sort=created
Information link: http://brew.sh/index_zh-cn .html
Information link: http://blog.csdn.net/jiandanjinxin/article/details/53175121
Step 2: After pip is installed successfully, start using pip to install the library
(1) At the beginning Usage statement: pip3 install git+https://github.com/RNCryptor/RNCryptor-python.git#egg=rncryptor
always prompts the following log:

The approximate meaning is: the current python3 version is 8.1. 1. It needs to be upgraded to 9.0.1. Check it in pycharm. It is indeed the case.
Information link: http://www.cnblogs.com/wayde-Z/p/6086083.html
(2) Start upgrading pip version, after going through many pitfalls, I finally found the answer. You only need to execute: execute
pip3 install pymysql
or an error is reported. The expert answered that you need to execute it here:
pip3 install --upgrade pip
pip finally prompts to upgrade the installation. It worked. Let’s start using pip to install the library
Step 3: Finally! We really have to start using pip to install the pycrypto library
(1) Execute the installation statement:
pip3 install git+https://github.com/ RNCryptor/RNCryptor-python.git#egg=rncryptor
Prompt:
This is a prompt that this library has been installed. If you don’t give up, continue to restart pycharm and rerun the program, but it still prompts that the library is missing! Go to the folder where python is located and find this library. In short, python3 cannot find this library
(2) Directly follow the log prompts to install this library and execute it with the command line:
pip3 install Crypto , still prompting the above error
Continue to execute: pip3 install pycrypto Still prompting the above error
Link: http://www.cnblogs.com/xueranzp/p/5010893.html
Directly execute the uninstall statement: pip3 uninstall pycrypto, prompts that the uninstallation was successful! !
Execute again: pip3 install pycrypto. It prompts that the installation is successful! After restarting pycharm. Run the project and it is finally ready to run! ! !


The above is the detailed content of Detailed explanation of why python prompts ImportError: No module named Crypto when importing a module. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template