Error setting up a virtualenv with jython 2.7b3

1.7k views Asked by At

I'm trying to set up a virtual environment using jython 2.7b3. I'm running Mac OS 10.8.5 in case that's relevant.

I installed virtualenv (1.11.6) using jython and easy_install as recommended here: http://www.jython.org/jythonbook/en/1.0/appendixA.html

But when I run:

$ /usr/local/jython/jython2.7b3/bin/virtualenv jython-venv

I get the output:

Cannot find file /usr/local/jython/jython2.7b3/Include (bad symlink)
New jython executable in jython-venv/bin/jython
ERROR: The executable jython-venv/bin/jython is not functioning
ERROR: It thinks sys.prefix is u'/usr/local/jython/jython2.7b3' (should be  u'/..../jython-venv')
ERROR: virtualenv is not compatible with this system or executable

(Where /..../jython-venv stands for the path to the new virtual environment I created.)

When I run jython-venv/bin/jython I get a normal jython prompt:

$ jython-venv/bin/jython
Jython 2.7b3 (default:e81256215fb0, Aug 4 2014, 02:39:51) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_51
Type "help", "copyright", "credits" or "license" for more information.
>>> 

What am I missing? Why does virtualenv think the executable doesn't work, even though it seems to be functioning OK by itself? Is it just a matter of telling it the correct sys.prefix? If so how can I do that?

Many thanks in advance for your help...

1

There are 1 answers

2
pilikia On

Found the problem and solution described here: http://seletz.github.io/blog/2012/04/06/jython-classpath-virtualenv/

Apparently there is a bug in virtualenv that causes this issue when JYTHON_HOME is set, which was my problem.

As soon as it's unset with unset JYTHON_HOME, virtualenv works (almost) as expected.

$ echo $JYTHON_HOME
/usr/local/jython/jython2.7b3
$ unset JYTHON_HOME
$ echo $JYTHON_HOME

I say "almost" as expected because it still had an issue installing pip. Luckily that problem and its solution described here: https://gist.github.com/skyl/ea2ab1c62a547e381411