This looks like an environment setting problem. When you say “a new python3 file on Jupyterhub” you mean a notebook?
What I would do is look in the JupyterHub documentation and check how to specify environment variables for the kernels. Then you will need to add the same PYTHONPATH and LD_LIBRARY_PATH that thisroot.sh sets (the fact that you put it in .profile does not seem to have any effect over the kernels of JupyterHub).
placed into a file which I created and named environment.py placed in /opt/tljh/config/jupyterhub_config.d/ (root privileges requested).
By doing this, the correct PATH is imported into JupyterHub.
Then an additional issue appeared. The python kernel of the notebooks is by default set to py3.7, while I built ROOT with py3.6, so actually I’m not able to import ROOT from the notebook because of this incompatibility.
Additional suggestion are highly appreciated. In the meantime, thanks to @etejedor for the help!
The python kernel of the notebooks is by default set to py3.7, while I built ROOT with py3.6, so actually I’m not able to import ROOT from the notebook because of this incompatibility.
You can try a couple of things. The first one would be to build ROOT with the same Python3.7 installation that Jupyter uses. More details on how to point ROOT to a particular Python installation here:
Another option would be to modify the Jupyter Python3 kernel to point to the Python3.6 installation that ROOT was built against. For that, you can check where the kernel is installed with:
jupyter kernelspec list
And then modify the kernel.json of the Python3 kernel directory to point to your python3.6.
Hello,
I’m trying to achieve both options, starting from building ROOT with py3.7. I take the interpreter from the installation directory related to TLJH, in order to match the exact version. The message I get when I try to run
Citing this thread, I also tried to add the option -DPYTHON_LIBRARY=/opt/tljh/user/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.a and I get the following message:
-- Detected ROOT_VERSION 6.22.99
-- Looking for Python
-- Found PythonLibs: /opt/tljh/user/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.a (found version "3.6.9")
CMake Error at cmake/modules/SearchRootCoreDeps.cmake:230 (message):
Version mismatch between Python interpreter (3.7.3) and libraries (3.6.9).
ROOT cannot work with this configuration. Please specify only
PYTHON_EXECUTABLE to CMake with an absolute path to ensure matching
versions are found.
Call Stack (most recent call first):
CMakeLists.txt:129 (include)
-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/builddir/CMakeFiles/CMakeOutput.log".
Moreover, no file of the type libpython3.7.so is present.
Ok, then what I suggest is either try option 2 (modify the Jupyter kernel to point to Python3.6) or update your CMake to >=3.14 and try option 1 again.
The file CMakeCache.txt complicated things a lot.
The PYTHON_EXECUTABLE was correct, but the CMakeCache.txt was an old version, not updated. After having eliminated it, everything worked.
Thanks again @etejedor for the help