简体   繁体   English

Flask在虚拟环境中不起作用

[英]Flask doesn'T work in Virtual Environment

I have installed venv 我已经安装了venv

sudo pip3 install virtualenv

I have activated it 我已经激活了

source venv/bin/activate

I have installed Flask, while it was activated 激活时,我已经安装了Flask

sudo pip3 install Flask

But it doesn't work as soon as I run python3 and then use 但是一旦我运行python3然后使用它就无法正常工作

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. 使用源VENV / bin中/激活运行的Python它将显示当前使用的蟒如果路径指向目录,其中所述虚拟环境被放置,则意味着其运行细的命令切换到虚拟环境之后。 After this try running pip list to display the list of installed packages in the virtual environment. 之后,请尝试运行pip list以显示虚拟环境中已安装软件包的列表。 It will tell you whether flask is installed and placed inside the current environment or not. 它会告诉您烧瓶是否已安装并放置在当前环境中。

Try from flask import Flask . 尝试from flask import Flask It's should help 应该有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM