[PYTHON] Enable Jupyter Notebook with conda on remote server

Introduction

Note that the environment construction on the remote server is quite different from the local environment, so don't forget it.

1. Building a virtual environment

Use conda instead of pipenv.

$ conda create -n [Virtual environment name] python==[version]

After entering the virtual environment, perform the operations from 2. onward.

$ source activate [Virtual environment name]  #Enter the virtual environment
$ source deactivate            #Get out of the virtual environment

Update pip itself.

$ pip install --upgrade pip

2. Package installation

Execute the following only for the first time.

$ conda config --append channels conda-forge

This will increase the package installation success rate (easiness to find).

$ conda install [package name]==[version]
$ pip install [package name]==[version] #When you can't find it (not recommended?)

3. Jupyter Notebook settings

First, install the package.

$ conda install jupyter jupytext

Enter the following in order.

$ ipython

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password: [Enter password]
Verify password: [Enter password again]
Out[2]: 'sha1: [Hashed password]'  #I will use it later, so copy it

In [3]: exit

$ jupyter notebook --generate-config
$ vi ~/.jupyter/jupyter_notebook_config.py

The vi editor opens, so add the following at the end.

#jupyter settings
c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = '*'
c.NotebookApp.password = 'sha1:[Hashed password]'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888

#jupytext settings
c.NotebookApp.contents_manager_class = 'jupytext.TextFileContentsManager'
c.ContentsManager.default_jupytext_formats = 'ipynb,py'

You can now use Jupyter Notebook.

$ jupyter notebook  # http://[IP address]:8888/Login from

References

Note on how to use the conda command Start jupyter notebook on the remote server and use it in the local environment [How to install Jupyter Notebook using Pipenv] (https://qiita.com/SUZUKI_Masaya/items/76b927b9812d77d33e57)

Recommended Posts

Enable Jupyter Notebook with conda on remote server
Start jupyter notebook on GPU server (remote server)
Build jupyter notebook on remote server (CentOS)
Run Jupyter notebook on a remote server
Formatting with autopep8 on Jupyter notebook
Try SVM with scikit-learn on Jupyter Notebook
Try using conda virtual environment with Jupyter Notebook
Remotely open Jupyter notebook launched on the server
Monitor the training model with TensorBord on Jupyter Notebook
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
Using Graphviz with Jupyter Notebook
Use pip with Jupyter Notebook
High charts on Jupyter notebook
View PDF on Jupyter Notebook
Use Cython with Jupyter Notebook
Play with Jupyter Notebook (IPython Notebook)
Run Jupyter Notebook on windows
Server management with Jupyter (1) import
Write charts in real time with Matplotlib on Jupyter notebook
Try clustering with a mixed Gaussian model on a Jupyter Notebook
Allow external connections with jupyter notebook
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
Run azure ML on jupyter notebook
Use markdown with jupyter notebook (with shortcut)
Add more kernels with Jupyter Notebook
Convenient analysis with Pandas + Jupyter notebook
Try running Jupyter Notebook on Mac
Use nb extensions with Anaconda's Jupyter notebook
Use apache Spark with jupyter notebook (IPython notebook)
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
I want to blog with Jupyter Notebook
Use Jupyter Lab and Jupyter Notebook with EC2
Make Jupyter Notebook a service on CentOS
Django + Apache with mod_wsgi on Windows Server 2016
Clone the github repository on jupyter notebook
How to use jupyter notebook with ABCI
Settings when reading S3 files with pandas from Jupyter Notebook on AWS
GPU check of PC on jupyter notebook
Display histogram / scatter plot on Jupyter Notebook
Linking python and JavaScript with jupyter notebook
Use vim keybindings on Docker-launched Jupyter Notebook
[Jupyter Notebook memo] Display kanji with matplotlib
Rich cell output with Jupyter Notebook (IPython)
Build a proxy server with nginx on multiple remote servers using Ansible
When I connect to a remote Jupyter Server with VScode, it's remote but local
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Install matplotlib and display graph on Jupyter Notebook
Log in to the remote server with SSH
How to debug with Jupyter or iPython Notebook
[Jupyter Notebook / Lab] 3 ways to debug on Jupyter [Pdb]
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)
Data analysis for improving POG 2 ~ Analysis with jupyter notebook ~
Play with custom image notebook on Kubeflow v0.71
Using MLflow with Databricks ① --Experimental tracking on notebook -
Verify NLC accuracy with Watson Studio's Jupyter Notebook
I tried launching jupyter nteract on heroku server
[Pythonocc] I tried using CAD on jupyter notebook
Simply display a line graph on Jupyter Notebook
Fill the browser with the width of Jupyter Notebook
Settings when using Jupyter Notebook under Proxy server