I'm looking to make the switch from JupyterLab to Apache Zeppelin. One of the things that I liked about JupyterLab was that I could pipenv install jupyter
, and then my Python code in the notebook was natively using my app's Python environment. This enabled me to run a shell that could talk directly to my app's models and views.
However, I like the Helium Packages (Spark/Beam/Neo4j/Bash) and Dynamic Forms of Zeppelin in comparison to the ipython widgets/ nbextensions of the Jupyter ecosystem.
How can I tell Zeppelin to use my pyenv/venv when running %python
cells?
Info about my python venv:
$ pyenv activate MY_APP
$ which python
/Users/ME/.pyenv/shims/python
$ python
>>> import os
>>> os.environ['VIRTUAL_ENV']
'/Users/ME/.pyenv/versions/3.7.3/envs/MY_APP'
found this in /zeppelin/conf/interpreter.json of docker image apache/zeppelin:0.8.1 but struggling more than usual to map a desktop volume.
"python": {
"id": "python",
"name": "python",
"group": "python",
"properties": {
"zeppelin.python": {
"name": "zeppelin.python",
"value": "python",
"type": "string"
},
inside zeppelin notebook
import os
os.environ['PYTHONPATH']
[1] '/zeppelin/interpreter/python/py4j-0.9.2/src'
I'm sure I could pull this off with %sh
bash commands inside a live notebook, but is there a way I can set the python env in a zeppelin config?
Figure out your Python executable
$ pyenv activate my_env
(my_env) $ python
>>> import sys
>>> sys.executable
/Users/me/.pyenv/versions/my_env/bin/python
Then navigate browser to localhost:8080/#/interpreters
and search for python.
Change zeppelin.python
to the output of sys.executable
Save + Restart zeppelin
You'll also want to change zeppelin.pyspark.python
to the same path as the spark's pyspark interpreter won't infer the path of your regular python interpreter.