user3827726
user3827726

Reputation: 1

no module named flask

I'm a beginner to flask, following the installation instructions from the website. I'm using python 3.4 and I've run all the following code in my command prompt

$ mkdir myproject
$ cd myproject
$ virtualenv venv
python executable in venv/bin/python
Installing distribute............done.

$ . venv/bin/activate

$ venv\scripts\activate

$ pip install Flask

I'm pretty sure the virtualenv is activated since venv is before every line of code. But now I'd like to import flask, but when I start up python in my cmd it says no module named flask. What am I doing wrong?

Upvotes: 0

Views: 1783

Answers (2)

Jan Vlcinsky
Jan Vlcinsky

Reputation: 44142

Virtualenv is always activated locally for the console

When you activate virtualenv, the activation is valid for current command line session.

If you open another console, it has completely independent status and initially does not know anything about any virtualenv.

It is perfectly fine, to have multiple consoles open an few of them sharing the same virtualenv.

Upvotes: 0

Martin Konecny
Martin Konecny

Reputation: 59671

Make sure the output of which python is pointing to the python binary inside your venv folder. Also make sure you are doing from flask import Flask inside python.

Here's my commands that worked just now

$ virtualenv venv
$ cd venv
$ . bin/activate
(venv)$ pip install Flask
(venv)$ python
>>> from flask import Flask

Upvotes: 1

Related Questions