[PYTHON] I want to use a virtual environment with jupyter notebook!

Background

It turned out that a code error occurs in the latest version of TensorFlow when I try to proceed with learning with "Deep Learning starting with TensorFlow" (Impress Takuya Niimura = author). Considering that the same situation will occur in the future, I wanted to master the construction of a virtual environment, so I created an environment. This article is a memorandum.

Purpose

-Create a virtual environment and install TensorFlow 1.4 -Use the created virtual environment with jupyter notebook

procedure

Install the library that will add the kernel to your base environment.

pip install environment_kernels

Next, create a new virtual environment. I also installed python, jupyter, and ipykernel.

conda create -n hoge python=3.6 jupyter ipykernel
conda info -e
$base * C:/Users/...  #Active environment
$hoge    C:/Users/...

Activate the virtual environment you created.

activate hoge
$(hoge) C:\Users\...>  #Is displayed, OK

Create a config file for jupyter notebook.

jupyter notebook --generate-config

.jupyter / jupyter_notebook_config.py will be created, so add the following to an appropriate location.

c.NotebookApp.kernel_spec_manager_class = 'environment_kernels.EnvironmentKernelSpecManager'
c.EnvironmentKernelSpecManager.conda_env_dirs=['/home/User/Anaconda3/envs/']

In [], specify the folder where the virtual environment is saved.

Set the virtual environment in the kernel.

ipython kernel install --user --name=hoge

For the time being, the virtual environment can be used in this state. Launch jupyter notebook and it should be added to the kernel tab. After that, please like it as it is boiled or baked.

Referenced articles, etc.

Using both Python 2.x and Python 3.x in IPython Notebook https://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook

A note about adding python3 Kernel in Jupyter Notebook

https://qiita.com/suzukihi724/items/b29f3fe9df96f7102ec9

Add the virtual environment created by Anaconda to the Kernel of Jupyter Notebook

https://kazusa-pg.com/jupyter-notebook-use-virtual-env-kernel/

How to easily switch the virtual environment created by Conda on Jupyter

https://qiita.com/yoppe/items/38005f415a5b8b884c7d

Settings for easy selection of multiple kernels in Jupyter

https://qiita.com/tomochiii/items/8b937f15c79a0c3eae0e

[Jupyter] Use Anaconda virtual environment with jupyter notebook

https://nodaki.hatenablog.com/entry/2019/04/03/223102

Recommended Posts

I want to use a virtual environment with jupyter notebook!
I want to blog with Jupyter Notebook
I want to start a jupyter environment with one command
I wanted to use jupyter notebook with docker in pip environment (opticspy)
I want to use R functions easily with ipython notebook
I want to build a Python environment
How to use jupyter notebook with ABCI
I want to use a wildcard that I want to shell with Python remove
I wanted to create a smart presentation with Jupyter Notebook + nbpresent
How to use jupyter notebook without polluting your environment with Docker
I want to use MATLAB feval with python
I want to make a game with Python
Try using conda virtual environment with Jupyter Notebook
I want to use Temporary Directory with Python2
I don't want to use -inf with np.log
I want to use ip vrf with SONiC
I want to write to a file with Python
Use pip with Jupyter Notebook
Use Cython with Jupyter Notebook
Switch virtual environment with jupyter
How to use Jupyter Notebook
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
I want to climb a mountain with reinforcement learning
I want to easily build a model-based development environment
I want to work with a robot in python.
I want to split a character string with hiragana
I want to manually create a legend with matplotlib
I want to run a quantum computer with Python
I want to bind a local variable with lambda
When I tried to create a virtual environment with Python, it didn't work
I want to use mkl with numpy and scipy under pyenv + poetry environment
If you want to enter the virtual environment with jupyter, nb_conda_kernels is recommended
[Python] I want to add a static directory with Flask [I want to use something other than static]
[Python] I want to use only index when looping a list with a for statement
Make a sound with Jupyter notebook
I want to make a blog editor with django admin
Create a virtual environment with Python!
I want to make a click macro with pyautogui (desire)
Reflect the virtual environment created with Miniconda in Jupyter notebook
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS
I want to make a click macro with pyautogui (outlook)
[Python] I want to use the -h option with argparse
Use markdown with jupyter notebook (with shortcut)
I want to install a package from requirements.txt with poetry
I just built a virtual environment with AWS lambda layer
The usual way to add a Kernel with Jupyter Notebook
Easy to use Jupyter notebook (Python3.5)
I want to do ○○ with Pandas
[Visualization] I want to draw a beautiful graph with Plotly
I want to debug with Python
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS with anaconda
I want to set up a GUI development environment with Python or Golang on Mac
How to batch start a python program created with Jupyter notebook
I want to run Rails with rails s even in vagrant environment
I want to do a full text search with elasticsearch + python
I want to use an external library with IBM Cloud Functions
Build a comfortable psychological experiment / analysis environment with PsychoPy + Jupyter Notebook
[Introduction] I want to make a Mastodon Bot with Python! 【Beginners】
I really want to use GitHub Flavored Markdown (GFM) with Pelican!
I want to detect objects with OpenCV
Use nb extensions with Anaconda's Jupyter notebook