I need to add custom directory for Jupyterhub so the users can import python modules installed using pip.
We have an offline server running Jupyterhub. I loaded new docker image onto this server (docker image contains new python packages installed using pip in Dockerfile on another machine).
I found out, that Jupyter notebook has different PYTHONPATH than Docker image. The problem is that modules can be imported without any problem inside Docker but they can not be found inside Jupyter notebook.
I found out that when opening new notebook and appending the folder I found the modules are actually in inside the first cell:
import sys
sys.path.append('/opt/conda/lib/python3.7/site-packages')
works just fine and modules can be used without any problem.
I do not want users to have append the path every time they create a new notebook.
I changed Jupyterhub config file and added following to 'PYTHONPATH':
:/opt/conda/lib/python3.7/site-packages/
When I restart the Jupyterhub service and open the new Python3 notebook, following kernel error occurs:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/opt/conda/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.send(value)
File "/opt/conda/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 67, in post
model = yield gen.maybe_future(sm.get_session(path=path))
File "/opt/conda/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 170, in get_session
return self.row_to_model(row)
File "/opt/conda/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py", line 209, in row_to_model
raise KeyError
KeyError
Another problem appeared after appending the path in the notebook:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-26-31ba9e12ccc0> in <module>()
1 import sys
----> 2 import bitarray
/opt/conda/lib/python3.7/site-packages/bitarray/__init__.py in <module>()
9 Author: Ilan Schnell
10 """
---> 11 from bitarray._bitarray import _bitarray, bitdiff, bits2bytes, _sysinfo
12
13 __version__ = '0.9.0'
ModuleNotFoundError: No module named 'bitarray._bitarray'
Any help is greatly appreciated!