Running python script from inside virtualenv bin is not working

Viewed 129341

I have a script I want to be available globally. I've started it with the standard hashbang:

#! /usr/bin/env python

And linked it into the bin directory of my virtualenv:

~/environments/project/env/bin/myscript

And added that directory to my path. When I run the command:

myscript

I get an import error with one of the libraries. However, if I activate the virtual environment and run the script, it works as expected.

I've ruled out a problem with the symlink (I've also tried just moving the script inside the bin folder). I've also tried running the script with python

python ~/environments/project/env/bin/myscript

Previously I was using a script that activated the environment and then ran my script, but I was under the impression that script run from this folder should run with the virtualenv's interpretor and site-packages. Any ideas of why this might not be working or some ways I could debug this?

5 Answers
Related