custom environments
Creating the environment
1. Open a new Terminal
2. in case the environment should be available permanently
conda config --add envs_dirs /home/jovyan/.conda_envs
3. create environment with conda
conda create --name myenv
4. initialize bash shell
conda init bash
5. restart shell
source ~/.bashrc
6. activate environment:
conda activate myenv
Activating an environment
these steps need to be executed to activate an environment
1. initialize bash shell
conda init bash
2. restart shell
source ~/.bashrc
3. activate environment:
conda activate myenv
Exporting environment to custom Kernel image
First, activate your virtual environment *previous step* and install ipykernel:
pip install --user ipykernel
We need to manually add the kernel if we want to have the virtual environment in the Jupyter Notebook. That is why we need to add it by running this code.
python -m ipykernel install --user --name=myenv
when creating a new notebook, you can choose your new kernel image
If you have finished with the virtual environment and did not need it anymore, you could remove it using this command:
jupyter kernelspec uninstall myenv
Installing packages in user space
So that pip installs don't get lost after restart
pip install --user package_name
No Comments