Try using conda virtual environment with Jupyter Notebook

This article

Today, I would like to use the conda virtual environment with `` `Jupyter Notebook. google colaboratory```It comes in handy when dealing with datasets that cannot be taken out to.

Premise

--Installation of Anaconda is complete -- Jupyter Notebook has been installed --Created an existing conda virtual environment (named `<env_name>`)

Preparation

--Install the Jupyter Notebook plugin environment_kernels.

pip install environment_kernels

This time, I installed it in the default `` `baseof the conda virtual environment. The reason is that I want to open it with the operation Win +" r "-> " Jupyter Notebook "```!

Copy of virtual environment

I want to use an existing virtual environment with Jupyter Notebook. However, you need to install Jupyter Notebook in that environment.

I want to keep the existing one if possible, so here

--I decide to clone the virtual environment.

# <env_name>Is an existing conda virtual environment
# <new_env_name>Give the name of the new virtual environment
conda create -n <new_env_name> --clone <env_name>

Install Jupyter Notebook in clone virtual environment

Install Jupyter Notebook into your virtual environment so that the Jupyter Notebook plugin environment_kernels will recognize it.

--Switch to the cloned virtual environment.

conda activate <new_env_name>

--Install Jupyter Notebook.

pip install jupyter

Jupyter Notebook config

--Generate a configuration file

jupyter notebook --generate-config

--Edit the configuration file ――Since I have Windows, I edit it with notepad. --Please change the following \ <user_name > to suit your environment.

notepad C:\Users\<user_name>\.jupyter\jupyter_notebook_config.py

--Add the following two lines to the end of the opened file --Depending on how you installed Anaconda, the path may not be as shown in the example below. Please change accordingly. --There are various ways to specify the Python path, such as changing the delimiter from "" to "\", "/", or r "~". In the following, "" in the window path string is changed to "/". </ font>

c.NotebookApp.kernel_spec_manager_class='environment_kernels.EnvironmentKernelSpecManager'
c.EnvironmentKernelSpecManager.env_dirs=['C:/Users/<user_name>/.conda/envs/']

#The following one line is 2019-12-13 It didn't work now
# c.EnvironmentKernelSpecManager.conda_env_dirs = ['C:/Users/0000112345/.conda/envs/']

--After editing, save and close

Check with Jupyter Notebook

--Launch Jupyter Notebook -Confirm that the environment has been switched with "Kernel"-> "Change kernel"

jupyter_notebook_condaenv.png

What didn't work

--I overlooked that the target side also needs a Jupyter Notebook to be recognized by the plugin.

from now on

I want it to look the same as Google Colaboratory. What should i do? ??

reference

Recommended Posts

Try using conda virtual environment with Jupyter Notebook
Using Graphviz with Jupyter Notebook
Try using Jupyter Notebook dynamically
Switch virtual environment with jupyter
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Reflect the virtual environment created with Miniconda in Jupyter notebook
I want to use a virtual environment with jupyter notebook!
Try SVM with scikit-learn on Jupyter Notebook
Automatically switch virtual environment with conda + direnv
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)
Create a virtual environment with conda in Python
Enable Jupyter Notebook with conda on remote server
Error running Jupyter Notebook in Anaconda virtual environment
Try using Jupyter Notebook of Azure Machine Learning
Virtual environment with Python 3.6
Try using PythonTex with Texpad.
Use pip with Jupyter Notebook
Try using matplotlib with PyCharm
Use Cython with Jupyter Notebook
Play with Jupyter Notebook (IPython Notebook)
Try running Python with Try Jupyter
Try using folium with anaconda
python3.8 venv environment jupyter notebook
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS
Machine learning with Jupyter Notebook in OCI Always Free environment (2019/12/17)
Try clustering with a mixed Gaussian model on a Jupyter Notebook
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS with anaconda
Activate Anaconda's virtual environment with PowerShell
Allow external connections with jupyter notebook
Formatting with autopep8 on Jupyter notebook
Build python virtual environment with virtualenv
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
Easy Jupyter environment construction with Cloud9
Create a virtual environment with Python!
Building a virtual environment with Python 3
[MEMO] [Development environment construction] Jupyter Notebook
Use markdown with jupyter notebook (with shortcut)
Try running Jupyter with VS Code
Add more kernels with Jupyter Notebook
Build IPython Notebook environment with boot2docker
Convenient analysis with Pandas + Jupyter notebook
Using Chainer with CentOS7 [Environment construction]
Try running Jupyter Notebook on Mac
Somehow I tried using jupyter notebook
Operation memo of Conda virtual environment
Try using Python's networkx with AtCoder
Try starting Jupyter Notebook ~ Esper training
Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
PATH when using ANACONDA virtual environment with Pycharm (as of Mac 2020/10/03)
Try using virtualenv, which can build a virtual environment for Python
How to use jupyter notebook without polluting your environment with Docker
Build a comfortable psychological experiment / analysis environment with PsychoPy + Jupyter Notebook
Debug settings in virtual environment when using Pipenv with VS Code
Build jupyter notebook environment with Visual Studio Code (VS Code) Mac version
How to quickly create a machine learning environment using Jupyter Notebook on macOS Sierra with anaconda
code-server Local environment (3) Try using VSCode Plugin
Use nb extensions with Anaconda's Jupyter notebook
Build Jupyter Lab (Python) environment with Docker
I wanted to use jupyter notebook with docker in pip environment (opticspy)
Use apache Spark with jupyter notebook (IPython notebook)