Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change conda environment in kernel #121

Closed
iguy0 opened this issue Oct 19, 2023 · 4 comments
Closed

Unable to change conda environment in kernel #121

iguy0 opened this issue Oct 19, 2023 · 4 comments

Comments

@iguy0
Copy link

iguy0 commented Oct 19, 2023

Hi,

I'm trying to add/change the conda/python environment and i'm unable to do so.

Steps to reproduce:

docker run --gpus all -d -it -p 8848:8888 -v /home/USER:/home/jovyan/work -e GRANT_SUDO=yes -e JUPYTER_ENABLE_LAB=yes --user root cschranz/gpu-jupyter:v1.5_cuda-11.6_ubuntu-20.04_python-only

Log into JupyterLab and add a different kernel/conda environment using the terminal

mkdir /home/jovyan/envs
conda init bash
exec $SHELL
conda create -p /home/jovyan/envs/python3.11 python=3.11
conda activate /home/jovyan/envs/python3.11
pip install --user ipykernel
python -m ipykernel install --user --name=python3.11
conda deactivate

at this point the kernel is available, but selecting the kernel gives me this

2023-10-18 21_25_53-Untitled ipynb - JupyterLab and 60 more pages - Profile 1 - Microsoft​ Edge

Installing packages via pip and conda end up under /opt/conda when importing them uses the 3.11 environment, and gives a ImportError error. How to fix this ?

@iguy0
Copy link
Author

iguy0 commented Oct 20, 2023

I got it going. The solution and additional useful commands are below:

Create environment paths and init conda - this is executed from Terminal in Jupyterlab

mkdir /home/jovyan/envs
conda init bash
exec $SHELL

Install in conda base environment

conda install nb_conda_kernels # https://github.com/Anaconda-Platform/nb_conda_kernels

Install new Environment and kernel

conda create -p /home/jovyan/envs/python3.11 python=3.11.6
conda activate /home/jovyan/envs/python3.11
conda install ipykernel
sudo ipython kernel install --name=python3.11 --display-name "Python 3.11 (Darts)"
conda deactivate

Restart container to recognize new kernel

Remove kernel

jupyter kernelspec list
jupyter kernelspec uninstall unwanted-kernel

@iguy0
Copy link
Author

iguy0 commented Oct 20, 2023

Not a solution for the original issue but allows me to create additional environments/kernels

@benz0li
Copy link
Contributor

benz0li commented Dec 7, 2023

@ChristophSchranz
Copy link
Collaborator

Closing as there were no contributions for a while and it seems there is a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants