Reputation: 3977
Trying to get SQLAlchemy working with python. I create a virtual Python env like so:
mkdir project
cd project
virtualenv project-env
project-env/bin/pip install SQLAlchemy
This all runs with no issues. Now I place a python script in the root of the project folder (not the project-env) folder. The first two lines of the script are like so:
#!project-env/bin/python
from sqlalchemy import *
When I run the script I get an error: ImportError: No module named sqlalchemy
. What am I doing wrong here? Should the script be placed in the project-env
folder or outside?
Upvotes: 0
Views: 1005
Reputation: 169
You need to activate the virtual environment before running the script. The script can be wherever you want it to be. For example the terminal should show the virtual environment name before you run the code.
Upvotes: 2