No module named flask using virtualenv

前端 未结 12 1261
生来不讨喜
生来不讨喜 2020-12-29 22:42

I am following these steps to learn flask http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world/page/0#comments

I ran this command to create

相关标签:
12条回答
  • 2020-12-29 23:10

    This problem can also arise if the port is not available. Try running on different port.

    0 讨论(0)
  • 2020-12-29 23:14

    Make sure your virtualenv is activated. Then You check on the PYTHONPATH of that virtualenv. Is there a flask package (folder) installed in that directory.

    If you unsure whether you have installed flask, just run the following command to see all the packages you have installed pip list or pip show flask. Do you see flask there? If not you can run pip install flask

    0 讨论(0)
  • 2020-12-29 23:16

    If nothing else helps, check that in your code it is:

    from flask import Flask
    

    I've tried many things before I've noticed my mistake. I had this in my code:

    from Flask import Flask
    

    When I have changed capitalized letter for the module name, i.e. flask then everything worked.

    0 讨论(0)
  • 2020-12-29 23:17

    Activate your virtual environment first with

    source bin/activate envName
    

    Then try to run your command again

    0 讨论(0)
  • 2020-12-29 23:17

    I am running Python on windows 7. I had same problem No module named flask.

    I tried reinstalling python, venv but it did not work.

    Finally i run it like this

    1. Install venv the usual way
    2. go to scripts directory and activate
    3. C:\Python34\microb>c:\Python34\microb\fla\scripts\python run.py
    4. here microb is my project and fla is venv
    0 讨论(0)
  • 2020-12-29 23:25

    I had this same problem on three Raspberry Pi units at the same time; beat my head against the wall trying to fix it for several hours (reinstall flask via pip, apt and aptitude - no joy).

    Instead of:

    pip install flask
    

    I finally tried:

    pip install Flask
    

    Worked like a charm.

    0 讨论(0)
提交回复
热议问题