Using Jep with a different python version than default

799 views
Skip to first unread message

Sushant Hiray

unread,
May 19, 2016, 4:22:30 AM5/19/16
to Jep Project
Hi,

I'm currently using Jep on centos machine. The default python version is python2.6.

I also have python2.7 installed in a virtual environment and in the same venv I have various packages I need to import using Jep.

Is there any way I can direct Jep to use the python from the virtual environment and not the default python?

Your help will be appreciated.

Thanks,
Sushant

Nathan Jensen

unread,
May 19, 2016, 8:58:51 AM5/19/16
to Jep Project
That should be possible but I have not personally tried it.  Try the following:

Set the environment variable PATH to /path/to/your/virtualenv/bin:$PATH
Set the environment variable LD_LIBRARY_PATH to /path/to/your/virtualenv/lib:$LD_LIBRARY_PATH

Please let us know if that works or not.

--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project...@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/8171afe9-e01b-4410-902e-2e55ac44da35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sushant Hiray

unread,
May 26, 2016, 12:56:53 PM5/26/16
to Jep Project
Hi Nathan,

Thanks for the reply. I tried and it worked successfully.

I've a follow up question. 
I'm trying to import tensorflow into my scala application. There is a minor caveat:
TensorFlow needs a glibc version which is different than the default version on my system.

This is how I run python to import the relevant shared library:

/opt/tensorflow_dependencies/lib/x86_64-linux-gnu/ld-2.17.so ~/.conda/envs/testflow/bin/python


Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:08:32)


[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2


Type "help", "copyright", "credits" or "license" for more information.


Anaconda is brought to you by Continuum Analytics.


Please check out: http://continuum.io/thanks and https://anaconda.org


>>> import tensorflow
>>>




Inside the interpreter that opens, I can import tensorflow successfully

Now, I'm slightly unclear on how exactly jep creates its python interpreter. 

If I create an alias for python such as below:

alias python=/opt/tensorflow_dependencies/lib/x86_64-linux-gnu/ld-2.17.so ~/.conda/envs/testflow/bin/python


will jep be able to initialise its interpreter with the required shared library? Or alternatively is there any environment variable I can set to achieve the same.

Essentially an abstracted form of the question would be, does jep fire the  python command internally to create its instance of interpreter.

Nathan Jensen

unread,
May 26, 2016, 10:51:16 PM5/26/16
to Jep Project
I can't answer that definitively.  Did you try it?

Jep is using the CPython API to launch its interpreter and associated sub-interpreters.  https://docs.python.org/2/c-api/init.html#initializing-and-finalizing-the-interpreter

I believe Python itself goes through some of same methods when you run from a command line, but I don't know how to confirm that.  Regardless, given that PATH and LD_LIBRARY_PATH affect which Python libraries Jep uses, I think your example will work.  You'd have to try it to find out though.

Xsank Mar

unread,
Dec 12, 2017, 7:10:40 AM12/12/17
to Jep Project
Hi Sushant Hiray,

I have the same problem, my python version of mac os is 2.7.10, i want to use python 3.6.0 instead. 
but it is not works after setting the PATH environment.  (Infact, it is success about the bash settings)
The jep', sub-interpreter is always python 2.7.10.
How do you do that?

thank you

在 2016年5月27日星期五 UTC+8上午12:56:53,Sushant Hiray写道:
Reply all
Reply to author
Forward
0 new messages