Conda Enviroments use in %python interpreter
For the use of conda enviroments in the notebook module of notebooks, the %python.conda sub-interpreter is used with the following options:
Get conda information:
%python.conda info
List all environments:
%python.conda env list
Create a conda environment:
%python.conda create --name [ENV NAME]
Activate an environment (the python interpreter is restarted):
Disable environment
Get the list of packages for the current environment
Install a package from conda repositories
Uninstall a package
For the use of conda environments in the notebook module of notebooks, the %python.conda sub-interpreter is used with the following options:
Creating the environment in a notebook
The first step is creating the conda environment.
%python.conda create --name py37 python=3.7
In the previous example we are creating a new environment based on Python 3.7 and named py37
Then we go on to activate it in order to install the necessary libraries:
%python.conda activate py37
For example, we try to import the pandas library
%python
import pandas
We verify that since it is not installed it will give us an error, so we launch its installation from conda
%python.conda install pandas
And when you finish the previous step, it is now possible to import the library correctly
Finally, we deactivate the environment
%python.conda deactivate
Python environment versions on notebooks
Keep in mind that there are limitations to the version of python that can be used (and therefore created in an environment).
For version zeppelin 0.8.2 (onesait platform < 5.0.0) → the maximum python version is 3.7
For zeppelin versions 0.10.1 (onesait platform >= 5.0.0) → the maximum python version is 3.9
Using an environment type in a notebook process
The typical use in a notebook process would have 4 points to take into account:
Have the environments created for each type of environment necessary in the notebooks
Using a %python interpreter other than “shared” to allow parallel launches of python processes
Activation at the start of the notebook of the desired environment to have the necessary libraries and versions
Disabling the environment when the notebook is terminated