Jupyter Notebook with Conda environment - jupyter-notebook

Do/should I active my conda enviroment whenever I'm using the jupyter kernel linked to that conda environment?

Related

How do i use a custom conda environment on a jupyter notebook running on aws sagemaker?

Completely new to aws. I'm trying to run a .ipynb file on a sagemaker notebook instance in Jupyter Lab. How do I install requirements?
I would like to create and activate a conda environment like this, but it's not working:
conda env create -f environment.yaml
conda activate ldm
What's the best and easiest way to have all dependencies installed?

How to use conda from Jupyter Lab terminal?

Question in the title. What I've tried: Installing nb_conda and nb_conda_kernels. This did allow me to choose the environment my kernel runs in. However, I am unable to use conda from the terminal inside the Jupyter Lab notebook.
Before launching Jupyter Lab:
(base)
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ conda activate general-ml
(general-ml)
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ jupyter lab
From Jupyter Lab terminal:
Change the kernel to run in the general-ml conda environment, then open up a notebook terminal:
wesle#DESKTOP-VV4V3ND MINGW64 ~/Jupyter Notebooks/jn-anomaly-detect (master)
$ conda info -e
bash: conda: command not found
as if it doesn't exist at all. Is there a known solution to this?
Edit:
I noticed that packages installed from Anaconda Navigator GUI are reflected live in Jupyter Notebook. This is an undesirable workaround as it is not efficient to open a new program, navigate through the gui, search for a package then install. All of this could be done from the terminal in 3 seconds.

C++14 no visible after installing xeus-cling in Jupyter (Ubuntu 18.04 - Anaconda)

I followed the installation of the xeus-cling (created an env, activated,installed xeus-cling there) and when I want to select the C++14 kernel in a jupyter notebook it only appears Python3. What am I doing wrong?
I had the same problem. Its because jupyter-notebook is not installed in your environment. The jupyter server which is starting is the global one hence you don't see the c++14 option. The solution is:
Create a new directory and git clone the repository.
Run the conda env create -f environmental.yml command in cmd.
Run the conda activate xeus-cling command.
Run the jupyter notebook command.
You should now be able to see the c++14 and c++17 options. Step 2 created the xeus-cling environment and installs all the correct package versions including the correct jupyter notebook version.
Install notebook in your environment.
conda install xeus-cling notebook -c QuantStack -c conda-forge
You need register new kernels in jupyter:
jupyter kernelspec install PREFIX/share/jupyter/xcpp11 --sys-prefix
jupyter kernelspec install PREFIX/share/jupyter/xcpp14 --sys-prefix
jupyter kernelspec install PREFIX/share/jupyter/xcpp17 --sys-prefix

Change conda environment of a running ipython notebook

I have a ipython jupyter-notebook open and running on a conda environment env1.
Is there a way to change the conda environment to env2 of the same running notebook ?
No. At the very least, you will have to restart the kernel in the new environment. And you cannot change conda environments from inside the kernel at all.
Anaconda has a special feature that detects kernelspecs in different environments. If that is enabled in your setup, you should be able to switch the kernelspec to the other environment, which automatically restarts the kernel. Note that ipykernel needs to be installed in the target environment.

How to change Jupyter kernel and conda environment from within Jupyter?

Use Case:
The cluster at my University has a JupyterHub instance. I have my own conda environments I like to use. Is there a way, after my Jupyter notebook has launched, for me to specify a conda environment and kernel?
You should first zip your conda environments and upload them to your jupyter instance inside Jupyterhub. After unzipping the environments open terminal.
Execute these command for each environment you want to be available as a kernel -
source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
Change the name and display name as per requirement.

Resources