I want to use Flask to develop a website but I am having already problems getting a simple demo app running.
I followed the complete installation tutorial of the flask website
Means:
If I now open the python console via python (while running venv) and I try from flask import Flask I get the error:
Traceback (most recent call last): File "", line 1, in ImportError: No module named 'flask'
Also running a simple Hello World app like the following gives the same error. If I try to install flask again in venv, the following is shown in the console:
from flask import Flask
application = Flask(__name__)
@application.route("/")
def hello():
return "hello world"
if __name__ == "__main__":
application.run()
For completeness: I already searched a lot on SO and google but could not find the same problem. Although I found a few related all of them had the problem that the one asking either forgot installing flask inside venv or forgot activating venv etc.
Also if I type which python it points correctly to the folder bin/python inside my venv folder.
Okay, I solved the issue: If I use python3 instead of python to execute my program or to open python console everything works as expected.
Still, this is weird, because (inside venv) doing which python3 points to the python3 file inside the bin folder of my venv, but which python points to a symbolic link inside the same folder, which points again to exactly the same python3 file.
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.