venv installed Flask successfully but it can't be imported

Answered

Hi guys,

 

Actually I'm quite new to Python/Flask/PyCharm, but I think to setup an venv shouldn't be that difficult but I did take me several hours without any result. Hope anyone can help.

 

What I want is to create a Flask project from PyCharm and run it. I installed Flask from settings, and when I activate venv under command line I can see that it's successfully installed (by pip list). I can run python in venv and import Flask successfully.

 

But when I run the project in PyCharm, it always tells me Flask can't be imported.

 

I've put a screen capture here https://www.dropbox.com/s/0utztd4tp6vb4i2/PyCharm_Flask.wmv?dl=0 so you can understand what I'm talking about.

 

Thanks for help

 

#####################################################################

It's solved. I names my project Flask so flask.py is generated which causes name conflict. Just use another project name/ python file name solves this problem.

 

Thanks

2 comments

First, very good job on the issue report. The video made it easy to understand.

Short answer: use a different name than "flask" for your project. Your examples work because you cd into the subdirectory and Python doesn't see "flask" in the directory name. PyCharm though has "flask" in the project root and finds that before looking for the installed package named "flask".

0

Ah, I see you edited the question to have the answer, disregard my response.

0

Please sign in to leave a comment.