-
Notifications
You must be signed in to change notification settings - Fork 4
DCProgs in virtual environments
I have had trouble getting the virtual env to correctly find the dynamic library (liblikelihood.so/dylib)
When using virtualenv-wrapper there is a number of postactivate/postdeactivate and so on scripts that we can make set the LD_LIBRARY_PATH and remove it again. (DYLD_LIBRARY_PATH on OSX)
Something like the following should work.
In postactivate to set DYLD_LIBRARY_PATH
export _OLD_DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$VIRTUAL_ENV/lib:$DYLD_LIBRARY_PATH"
In postdeactivate to remove the setting again
if ! [ -z ${_OLD_DYLD_LIBRARY_PATH+x} ] ; then
DYLD_LIBRARY_PATH="$_OLD_DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
unset _OLD_DYLD_LIBRARY_PATH
fi
If you have a global IPython4/Jupyter notebook setup you can create a kernel that runs with the global install of the notebook but inside the virtualenv. In the virtualenv you want to do pip install ipykernel
Next you have to define a kernel.json
file that tell Jupyter how to run the kernel.
This can be done mostly automatically see http://ipython.readthedocs.org/en/latest/install/kernel_install.html From the virtualenv running something like
python -m ipykernel install --user --name dcprogsenv --display-name "DCProgs Env"
should do the trick. Next we probably have to add the DYLD_LIBRARY_PATH to the kernel spec. See below:
The following will tell you where to install the kernels files. They go into a kernels subdirectory of the following:
jupyter --data-dir
/Users/jhn/Library/Jupyter
I.e in my case the kernel is defined in /Users/jhn/Library/Jupyter/kernels/dcprogstest/kernel.json
and you can add logo files there too if you wish named logo-32x32.png
and logo-64x64.png
The kernel file look like the following:
{
"language": "python",
"display_name": "DCProgs Python 3",
"argv": [
"/Users/jhn/Envs/dcprogstest/bin/python",
"-m",
"ipykernel",
"-f",
"{connection_file}"
],
"env": {
"DYLD_LIBRARY_PATH": "/Users/jhn/Envs/dcprogstest/lib/"
}
}
Here you have to modify the path to python inside the env and set the DYLD_LIBRARY_PATH same as above