Visgean Skeloru
Visgean Skeloru

Reputation: 2263

Virtualenv wont work on

I have build my virtual env with this command:

virtualenv env --distribute --no-site-packages

And then I have installed several modules (django etc) into env with pip, the problem is that when I wanted to run the code on the second machine it would not work, here is what I have done:

visgean@rewitaqia:~/scripty/project_name$ source ./env/bin/activate
(env)visgean@rewitaqia:~/scripty/project_name$ python
Python 2.7.1+ (r271:86832, Sep 27 2012, 21:12:17) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.__file__
'/home/visgean/scripty/project_name/env/lib/python2.7/site-packages/django/__init__.pyc'

but when I want to run it on the second machine:

(env)user@debian:~/project_name$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named django
>>> 

I wild error appears! The first machine is ubuntu, the second one is ubuntu. There seems to be some broken links in /home/user/project_name/env/lib/python2.7 , is that the problem? and if so, how should I prevent it/repair it?

Upvotes: 1

Views: 306

Answers (2)

Visgean Skeloru
Visgean Skeloru

Reputation: 2263

I have just noticed that I did have a wrong version of python on the second machine - debian does not have python2.7, installing 2.7 and pip for is the solution

Upvotes: 0

johnharris85
johnharris85

Reputation: 18916

If you are just copying the virtualenv to the second machine you may encounter some issues. From the virtualenv site:

Normally environments are tied to a specific path. That means that you cannot move an environment around or copy it to another computer. You can fix up an environment to make it relocatable with the command:

$ virtualenv --relocatable ENV

This will make some of the files created by setuptools or distribute use relative paths, and will change all the scripts to use activate_this.py instead of using the location of the Python interpreter to select the environment.

Note: you must run this after you've installed any packages into the environment. If you make an environment relocatable, then install a new package, you must run virtualenv --relocatable again.

Upvotes: 2

Related Questions