2

I'm working on my very very first python program/assignment, I'm new to not just the language but it's also my first time outside of languages like Java, C#, and .Net, so I'm having a difficult time picking it up.

I was given a bunch of example files and am supposed to run them to get a feel for what I need to do, except I get an error: ModuleNotFoundError: No module named 'flask_bootstrap'

I ran my bin/activate successfully and here's a bit of command line:

(p3) C:\Users\ritol\OneDrive\School\Project Files\Project Files\Flask\2f>python weather.py Traceback (most recent call last): File "weather.py", line 2, in from flask_bootstrap import Bootstrap ModuleNotFoundError: No module named 'flask_bootstrap'

(p3) C:\Users\ritol\OneDrive\School\Project Files\Project Files\Flask\2f>bin/activate 'bin' is not recognized as an internal or external command, operable program or batch file.

Here's a list of pip installs I was given to do, and it did them:

Flask==1.1.1
Flask-Bootstrap==3.3.7.1
Flask-Login==0.4.1
flask-marshmallow==0.10.1
Flask-Migrate==2.5.2
Flask-RESTful==0.3.7
Flask-Script==2.0.6
Flask-SQLAlchemy==2.4.0
Flask-Testing==0.7.1
Flask-WTF==0.14.2
itsdangerous==1.1.0
Jinja2==2.10.1

2f/weather.py:

from flask import Flask, render_template
from flask_bootstrap import Bootstrap
app = Flask(__name__)
bootstrap = Bootstrap(app)


@app.route('/')
def index():

etc...

I expect to get it to show something like a previous example did:

 * Serving Flask app "FlaskApp" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 173-453-384
 * Running on http://127.0.0.1:5001/ (Press CTRL+C to quit)

instead I get

Traceback (most recent call last):
  File "weather.py", line 2, in <module>
    from flask_bootstrap import Bootstrap
ModuleNotFoundError: No module named 'flask_bootstrap'
Citrus Rain
  • 119
  • 1
  • 4
  • 16
  • Is Flask-Bootstrap installed? ie: `python -m pip install flask-bootstrap` – delyeet Oct 09 '19 at 21:05
  • yes, the pip installs was a file that the professor gave us a command that went through that list (in a txt) and installed them all (there's more than what I pasted, but I felt those would show I had it installed) – Citrus Rain Oct 09 '19 at 21:15

3 Answers3

6

I had the same issue.

deactivate and activate the virtual environment solved it

deactivate
. venv/bin/activate
Serve Laurijssen
  • 9,266
  • 5
  • 45
  • 98
  • 1
    I am having the same issue. My python version is 3.8. I can not install flask_bootstrap. I tried to activate and deactivate but it also didn't help – Ferda-Ozdemir-Sonmez Jul 13 '21 at 15:17
1

While I waited for help, I was trying to figure out if I could get the virtual environment to be 'hooked up' to pycharm, and I found that pycharm made it's own virtual environment without the pip installs I was given, so I got the command line open into that, ran the pip installs, and now I can get it to run through pycharm.

So it works in the virtual environment that I discovered and added the installs to. (did not work from pycharm at all due to pycharm didn't know flask was installed and would error sooner) But not in the one that I was instructed on making. I don't know why.

Citrus Rain
  • 119
  • 1
  • 4
  • 16
1

You have to install flask_bootstrap using the following command:

pip install flask_bootstrap

In your case, you should not use a hyphen(-) In place of hyphen use underscore( _) then it might work.

Kishan Mehta
  • 2,598
  • 5
  • 39
  • 61
Ankit Singh
  • 327
  • 4
  • 12