I have installed venv
sudo pip3 install virtualenv
I have activated it
source venv/bin/activate
I have installed Flask, while it was activated
sudo pip3 install Flask
But it doesn't work as soon as I run python3
and then use
import flask
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'flask'
Try displaying the list of the installed packages in the virtual environment. After switching to virtual environment using source venv/bin/activate run the command which python it will display the current python in use if the path points to the directory where the virtual environment is placed then it means its running fine. After this try running pip list to display the list of installed packages in the virtual environment. It will tell you whether flask is installed and placed inside the current environment or not.
Try from flask import Flask
. It's should help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.