简体   繁体   中英

Module can be imported in python but cannot be used from command line

This is essentially the opposite of this problem: Import module works in terminal but not in IDLE

If I start a python session and try to import flask, then it works just fine. Despite that, if I just run flask from the terminal, it is not recognized.

I have confirmed that the locations which pip installs to is on my system path. (I'm on Windows 10 and I typed $Env:Path into Powershell to see that, for example, C:\Users\Zack\AppData\Roaming\Python\Python37\site-packages is in the system path.)

I am also sure that I did pip install --user flask not inside a virtual environment. When I run import flask; print(flask.__file__ import flask; print(flask.__file__ I see C:\Users\Zack\AppData\Roaming\Python\Python37\site-packages )

Any other ideas for what could be going wrong?

Edit: I'm trying to run flask run . To check the path python uses, I did (in python) import sys; for i in sys.path: print(i) import sys; for i in sys.path: print(i)

As Python language based on Python interpreter, before you use Python, it is necessarily to activate the Python env.

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