For the use of conda enviroments in the notebook module of notebooks, the %python.conda sub-interpreter is used with the following options:
Obtener información de Get conda information:
Code Block %python.conda info
Listar todos los enviromentsList all environments:
Code Block %python.conda env list
Crear un enviroment de condaCreate a conda environment:
Code Block %python.conda create --name [ENV NAME]
Activar un enviroment (se reiniciará el intérprete de pythonActivate an environment (the python interpreter is restarted):
Code Block %python.conda activate [ENV NAME]
Desactivar enviromentDisable environment
Code Block %python.conda deactivate
Obtener el listado de paquetes del enviroment actualGet the list of packages for the current environment
Code Block %python.conda list
Instalar un paquete desde los repositorios de condaInstall a package from conda repositories
Code Block %python.conda install [PACKAGE NAME]
Desinstalar un paqueteUninstall a package
Code Block %python.conda uninstall [PACKAGE NAME]
For the use of conda enviroments environments in the notebook module of notebooks, the %python.conda sub-interpreter is used with the following options:
Creación del enviroment en un notebook
...
Creating the environment in a notebook
The first step is creating the conda environment.
...
%python.conda create --name py37 python=3.7
En el ejemplo anterior estamos creando un nuevo enviroment con base python 3.7 y con nombre py37
Despues pasamos a activar el mismo con el objetivo de instalar la librerías necesariasIn 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
Intentamos por ejemplo importar la librería de pandasFor example, we try to import the pandas library
...
%python
import pandas
Comprobamos que al no estar instalada nos dará error, con lo que lanzamos su instalación desde 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
Y al terminar el paso anterior, ya es posible importar la librería de forma correctaAnd when you finish the previous step, it is now possible to import the library correctly
...
Finalmente, desactivamos el enviromentFinally, we deactivate the environment
...
%python.conda deactivate
Versiones del enviroment de python en notebooks
...
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) → la versión máxima de python es la the maximum python version is 3.7
Para versionesFor zeppelin versions 0.10.1 (onesait platform >= 5.0.0) → la versión máxima de python es la the maximum python version is 3.9
Uso tipo de un enviroment en un proceso de notebook
El uso tipo en un proceso de notebook tendría 4 puntos a tener en cuenta:
...
Tener los enviroments creados para cada tipo de enviroment necesario en los notebooks
...
Uso de un intérprete %python diferente a “shared” para poder permitir lanzamientos en paralelo de procesos de python
...
Activación al inicio del notebook del enviroment deseado para tener las librerías y versiones necesarias
...
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