Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import error with virtualenv

I have a problem with virtualenv. I use it regulary, I use it on my development machine and on several servers. But on this last server I tried to use i got a problem.

I created a virtualenv with the --no-site-packages argument, and then I installed some python modules inside the virtualenv. I can confirm that the modules is located inside the virtualenvs site-packages and everything seems to be fine.

But when i try to do:source virtualenv/bin/activate and then import one of the module python import modulename i get an import error that says that the module doesnt exist. How is it that this is happending? It seems like it never activates even thoug that it says it do.

Anybody have a clue on how to fix this?

like image 535
espenhogbakk Avatar asked Dec 15 '09 17:12

espenhogbakk


People also ask

Does virtualenv install pip?

Activating a virtual environmentAs long as your virtual environment is activated pip will install packages into that specific environment and you'll be able to import and use packages in your Python application.


1 Answers

After activating the virtual env, try:

$ python
>>> import sys
>>> sys.executable
...

... and see if you are running the expected executable.

Also check:

>>> sys.path
[...]
like image 160
codeape Avatar answered Sep 27 '22 23:09

codeape