2

I have installed venv

sudo pip3 install virtualenv

I have activated it

source venv/bin/activate

I have installed Flask, while it was activated

sudo pip3 install Flask

But it doesn't work as soon as I run python3 and then use

import flask

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'flask'
sunwarr10r
  • 4,420
  • 8
  • 54
  • 109

2 Answers2

2

Try displaying the list of the installed packages in the virtual environment. After switching to virtual environment using source venv/bin/activate run the command which python it will display the current python in use if the path points to the directory where the virtual environment is placed then it means its running fine. After this try running pip list to display the list of installed packages in the virtual environment. It will tell you whether flask is installed and placed inside the current environment or not.

  • Thanks! `which python` tells me `/root/venv/bin/python` and `which python3` tells me `/root/venv/bin/python3`. When running `pip list` it doesn't show me flask – sunwarr10r Aug 24 '17 at 14:08
  • 1
    If it does't show means it not installed while in virtual env mode run **pip install flask** and you are good to go – S. Uzair Tariq Aug 24 '17 at 17:14
-2

Try from flask import Flask. It's should help

Ranc58
  • 3
  • 3