python flask module cannot be called
PHP中文网
PHP中文网 2017-06-12 09:27:37
0
4
1012

The flask module has been installed using pip install (screenshot),
However, when executing the code in the command line cmd
ModuleNotFoundError: No module named 'flask
May I ask what I should do
Solution for beginners

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
仅有的幸福

This is a confusion caused by the possibility that the same computer has more than two Python environments. Please try executing the following code in all your Python environments:

from distutils.sysconfig import get_python_lib
print(get_python_lib())

For example, my computer has two Python environments, one is IDLE and the other is Anaconda. The above executed program will have the following different results:

c:\python36\Lib\site-packages

C:\ProgramData\Anaconda3\Lib\site-packages

It can be seen that the two Python environments are separate. One Python environment is isolated from the other. Your situation should be to confirm whether the environment where you pip install is consistent with the environment where you execute the code. You can check to see that the site-packages directory in the environment where you cannot run import flask does not have a flask directory, and the one you installed with pip install is another environment.

So first check the environment (get_python_lib() code), check whether the install and execution codes are consistent, and then install pip install flask.

阿神
pip install flask

python
>> import flask

If you’re right, you’re right

淡淡烟草味

You first open cmd, then enter python, and then perform the following operations:

import flask

Check if it runs successfully. It should be noted that if you are using an IDE such as PyCharm to install flask, it will not be found under cmd. Can only be run in PyCharm.

阿神

Have you installed this module

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template