I think this is not a bug of jupyterhub, but rather a problem with the configuration of environment variables and I need your help to understand where the problem is.
I have a fortran function compiled with f2py using the Intel ifort compiler. If I launch a python console or a jupyter notebook from my shell (that has the env variables such as LD_LIBRARY_PATH correctly set, I'm able to import the module generated by f2py.
But if I use jupyterhub (which is run as a system service in Ubuntu 16.04) then I get
ImportError: libifport.so.5: cannot open shared object file: No such file or directory
when importing the f2py-compiled module. The same happens if I launch a jupyter notebook with sudo.
Indeed, I can see that os.environ does not contain the relevant environment variables, but adding them using os.environ.append does not solve the problem. I still get the ImportError.
My question is thus how to configure jupyterhub to set the environment variables, LD_LIBRARY_PATH in particular, in a proper way so that I can import the f2py-compiled module.
Hi @teored90,
I'm not familiar with using f2py, but it does seem as if there is a configuration issue when you compile the the module using f2py.
In addition to the Numpy documentation, here's another resource that may help you:
@minrk may have additional suggestions too.
Hi @willingc,
thanks for answering. The Fortran code is compiled once with f2py, then I'm able to use it in python if it is run under my user's shell. The problem is in the dynamic linker, but I don't really know the structure of jupyterhub and how it spawns kernels etc., so I don't know where to put my hands.
If you have set the environment variable for the jupyterhub process itself, there is a whitelist of environment variables for each user's subprocess to inherit:
c.Spawner.env_keep.append('LD_LIBRARY_PATH')
Or, you can specify a particular value to be set in the spawner environments:
c.Spawner.environment = {
'LD_LIBRARY_PATH': '/opt/local/lib',
}
Yes! That was it! Thank you very much.