Center for Research and Application for Satellite Remote Sensing
Yamaguchi University
Setting-Up Python Environment
(Jupyter Notebook)
Contents:
This manual is to help in setting up the environment for running
python code as well as Jupyter notebook. Contents are arranged in
following manners:-
1. Creating a project
2. Activating the Environment
3. Installing the libraries
4. Listing the libraries
5. Making the virtual environment compatible with jupyter notebook
6. Jupyter notebook running
• Create a folder for the project
• Using GUI or
• Through shell: $ mkdir <project name>
• Change path: $ cd <project path>
• Creating a virtual environment for our project (generally same as project name for easy to remember) .
• $ conda create --name <virtual environment name> <python=version>
*In place of ‘conda’ we can also
use Python package manager
(‘pip’ or ‘pip3’). It will be mostly
same with few exceptions.
Creating a Project
• $ conda info —envs (For listing all the virtual environments)
• $ conda activate <virtual environment name> OR
• $ source activate < virtual environment name> (Activate the virtual
environment that we want to use for our project)
• After that we can see virtual environment name in starting of prompt.
• For deactivating this: $ conda deactivate
• For removing: $ conda env remove -–name <virtual environment name>
Activating the Environment
• $ conda install <libraryName1 libraryName2>
• Libraries for ex. OpenCV, TensorFlow, PyTorch, Keras etc.
• $ conda install tensorflow
• $ conda install pytorch torchvision -c pytorch
*detail description has been provided on other manual namely libraries_setup
Installing the libraries
• $ conda list (this command will list all the installed libraries/packages)
Listing the libraries
• $ conda install ipykernel
• $ ipython kernel install --user --name=<virtual environment name>
• $ jupyter notebook & (For running jupyter notebook)
• It will give a string with token (Highlighted with red ellipse) which can be copy pasted in browser
to run the instance of the notebook
Making the Virtual Environment compatible with Jupyter
• Create a new notebook using the Kernel which has been created in last exercise (for example here
Python_Learning).
Jupyter Notebook
• Jupyter notebook gives the flexibility to run a block of code (called cell) at a time, by using Run
button( ) or using shortcut Shift+Enter(return) key.
Output
Kernel
Writing a Simple Program in Jupyter Notebook