简体   繁体   中英

ModuleNotFoundError although package is installed

I amd getting: ModuleNotFoundError: No module named 'flask' , when trying to run a file that starts

from flask import Flask

  • i am using PyCharm on Ubuntu VM. Opened the terminal under venv directory. this is what i am getting:
 ~/PycharmProjects/project01/venv$ python -m flask --versionFlask 1.0.2 Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0] 

why does my interpreter can't find the flask module (i am guessing this is not specific to flask)? tried to browse through some previous suggested solution like this: ModuleNotFoundError: No module named 'flask' but it didn't solve the problem Made sure my PyCharm project interpreter is pointing to /home/my_user/PycharmProjects/project01/venv/bin/python and not another interpreter The only way i could have solved it is by installing the flask through the PyCharm Gui, but i really would like to understand why installing from the terminal with pip install flask didn't work

source venv/bin/activate

And install flask on the venv; after run the script using the venv python binary. - I believe you either have not installed flask in the virtual environment or you're not using the virtual environment python.

To check which python binary you're invoking:

whereis python

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.

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