How To Start Jupyter Notebook In Anaconda Python Virtual Environment

In this article i will tell you how to create python virtual environment, how to start jupyter notebook web server and how to create jupyter notebook file in anaconda.

1. Create A Python Virtual Environment In Anaconda.

  1. Click Start —> Anaconda —> Anaconda Navigator menu item.
    start--->anaconda--->anaconda navigator
  2. In the opened anaconda navigator window, click Environments menu item in left side, then click Create button at right bottom to create a python virtual environment.
    create virtual environment in anaconda navigator window
  3. If you want to create or manage anaconda virtual python environment with command line, you can read article How To Manage Anaconda Environments.

2. Start Jupyter Notebook In Above Python Virtual Environment.

  1. Click the green triangle button at the end of the python virtual environment, then click Open Terminal menu item in the popup menu list.
    python virtual environment open terminal menu item
  2. Then it will popup a command line console window. Go to the folder where you want to save your jupyter notebook files and python script files use cd command like below.
    (env_jupyter_example) C:\Users\song zhao>cd C:\WorkSpace\JupyterExampleProject\JupyterSlideBarExample
  3. Then run command jupyter notebook to start jupyter notebook web server. Then all the jupyter notebook files and folders will be saved in this folder.
    (env_jupyter_example) C:\WorkSpace\JupyterExampleProject\JupyterSlideBarExample>jupyter notebook
    [I 09:50:36.790 NotebookApp] JupyterLab extension loaded from C:\Anaconda\lib\site-packages\jupyterlab
    [I 09:50:36.791 NotebookApp] JupyterLab application directory is C:\Anaconda\share\jupyter\lab
    [I 09:50:36.865 NotebookApp] Serving notebooks from local directory: C:\WorkSpace\JupyterExampleProject\JupyterSlideBarExample
    [I 09:50:36.865 NotebookApp] The Jupyter Notebook is running at:
    [I 09:50:36.867 NotebookApp] http://localhost:8888/?token=7b4366a32146528811158f6400bec3f8afee5d8f7c1eb157
    [I 09:50:36.867 NotebookApp]  or http://127.0.0.1:8888/?token=7b4366a32146528811158f6400bec3f8afee5d8f7c1eb157
    [I 09:50:36.867 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [C 09:50:37.032 NotebookApp]
    
        To access the notebook, open this file in a browser:
            file:///C:/Users/song%20zhao/AppData/Roaming/jupyter/runtime/nbserver-2924-open.html
        Or copy and paste one of these URLs:
            http://localhost:8888/?token=7b4366a32146528811158f6400bec3f8afee5d8f7c1eb157
         or http://127.0.0.1:8888/?token=7b4366a32146528811158f6400bec3f8afee5d8f7c1eb157
  4. When above process complete, it will open a web browser and list all the files exist in current folder ( in this example is C:\WorkSpace\JupyterExampleProject\JupyterSlideBarExample> ).
    jupyter notebook list files web page
READ :   Python Profile Memory Usage And Object Graph Example

3. Create Jupyter Notebook Python File, Text File, Folder And Terminal.

  1. Click the New button at right side of the files list page, then it will popup menu list like below. There are 4 menu items in the list, you can create Python 3 notebook file, Text File, Folder and Terminal.
    new jupyter notebook file folder menu items
  2. Click New —> Python 3  menu item to create a jupyter notebook file. Then it will open a new web browser tab and you can write ipython command in the jupyter notebook file.
  3. If you want to run python 2 code in jupyter notebook, please read article How To Run Python 2 Code In Jupyter Notebook
  4. Click New —> Text File menu item to create a new text file.
  5. Click New —> Folder menu item to create a new folder. The default folder name is Untitled Folder.
  6. Click New —> Terminal menu item to open a terminal in a new web browser tab. In this terminal, you can run ls, pwd command no matter which OS ( Windows, Linux, MacOS etc ) you are using.
    create new terminal in jupyter notebook

4. Edit ( Rename, Move, Download, Delete etc ) Jupyter Notebook File, Folder.

  1. If you want to rename jupyter notebook file when edit it, just double click the file name ( Untitled ) at top left corner of the page, then it will popup a dialog to let you rename it.
    rename the jupyter notebook file by double click the file name
  2. You can also manage the jupyter notebook file or folder in the list page by check the checkbox before the file or folder name, then click Rename, Move, Download, Delete button at top area of the list.
    rename jupyter notebook file in files list pagerename folder name in jupyter notebook files list web page
  3. But if a jupyter notebook file is running ( such as you are editing it ) when you check it, it will show a brown color Shutdown button, you should first click this button to shutdown it first, then you can manage it.
    shutdown a running jupyter notebook file
READ :   How To Write Text To File In Ipython And Jupyter Notebook

Reference

  1. How To Use IPython Jupyter Notebook To Develop Python Code
  2. How To Manage Anaconda Environments
  3. How To Run Python 2 Code In Jupyter Notebook

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.