Let's run jupyter natively supported by VS Code with python3.8

2020/1/6 Fixed about virtualenv because venv was confused with virtualenv

venv and virtualenv were different ...!

What article?

It seems that VSCode natively supports jupyter, even without a web browser I was able to operate ʻipynb`.

In this article, I thought "Let's use it!" And created an environment with python3.8. There was a clogged part, so this is a shared article that says, "If you do this, it will work."

Create an environment for virtualenv instead of anaconda. </ strong>

Create an environment (operate at the command prompt)

environment

OS : Windows10 python : 3.8 editor : VSCode 1.40.2

Put the extension python in VS Code. I'm happy if I also include ʻIntelliCode`.

First of all, virtualenv

If you don't have virtualenv, do pip.

Install virtualenv


>pip install virtualenv

Then create a virtual environment.

\Users\usr1


>mkdir virtualenv
>cd virtualenv
>py -m virtualenv jupyter_env

~~~abridgement~~~
done.(Done when this is displayed)

Then start the created environment.

Start-up


>jupyter_env\Script\activate
(jupyter_env)>

If (jupyter_env) is displayed before the prompt >, the startup is complete.

From now on I'll work with VS Code

Start VS Code from the command prompt.

The current position is\User\usr1\virtualenv\


(jupyter_env)>code .

When VSCode starts, display the terminal with Ctrl + Shift + ~.

Upgrade pip

Just in case.

pip upgrade


(jupyter_env)>py -m pip install --upgrade pip

Put jupyter

Let's pip. Other necessary libraries are also included.

(jupyter_env)>pip install jupyter

I need a lot.

Create ipynb with VS Code

Press Ctrl + Shift + p to open the command palette. Once open, type jupyter and you'll see: commmand_palet.png

Select Python: Create New Blank Jupyter Notebook.

notebook.png

A jupyter-like screen was displayed.

Then select the python interpreter. Press Ctrl + Shift + p to open the command palette. Once open, type select and you'll see: notebook.png Select Python: Select Interpreter. The name of the environment you created will appear, so select it.

HelloWorld (cannot)

Let's move it immediately. Enter the following in the first cell and press Shift + ʻEnter` to execute.

helloworld


print('Hello world!')

It doesn't work. image.png

Cause of not working

Apparently there is a problem with the library called tornado used by jupyter.

Reference: Jupyter Notebook with Python 3.8 --NotImplementedError

Countermeasures

I was able to fix it by editing ʻasyncio.py of tornado`.

\venv\jupyter_env\Lib\site-packages\tornado\platform\asyncio.py


import asyncio    #Added below this
import sys

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Let's try it again.

Execute with Shift + ʻEnter`. image.png Hooray! You were able to stand at the starting point!

If you did not set it up, the port may have been used.

jupyter uses the 8888 port by default. Run netstat at the command prompt and see if 8888 is being used.

If that doesn't work, you may have failed to build the environment. Please check again.

(If you have any notices such as omission of consideration, please point them out in the comments!)

Let's have a good ** Jupi activity **!

reference

This article is based on articles written by other people.

@ simonritchie's article It seems that the Python extension of VS Code has native support for Jupyter, so I tried using it immediately.

@ matuya's article jupyter notebook in python3.8 venv environment

Recommended Posts

Let's run jupyter natively supported by VS Code with python3.8
Python with VS Code (Windows 10)
Let's run Excel with Python
Debug Python with VS Code
Try running Jupyter with VS Code
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
Install python with mac vs code
How to build Python and Jupyter execution environment with VS Code
Python (Windows 10) Virtual Environment / Package with VS Code
Debug with VS Code using boost python numpy
Use Python in Anaconda environment with VS Code
Make your Python environment "easy" with VS Code
Build a python execution environment with VS Code
Python local development environment construction template [Flask / Django / Jupyter with Docker + VS Code]
Run Python with VBA
Run prepDE.py with python3
Run Blender with python
Run iperf with python
Try touching the micro: bit with VS Code + Python
Allow real-time code checking in Python development with VS Code
VS Code settings for developing in Python with completion
Revive symbol search in Python workspace with VS Code
Get country code with python
Settings when developing App Engine / Python apps with VS Code
Run python with PyCharm (Windows)
Run Python with CloudFlash (arm926ej-s)
Run BNO055 python sample code with I2C (Raspberry Pi 3B)
Let's write python with cinema4d.
Run Label with tkinter [Python]
The story that Python stopped working with VS Code (Windows 10)
Try running Python with Try Jupyter
Mass generation of QR code with character display by Python
Using jupyter notobook with VS Code (mac OS) (personal memo)
I want to be able to run Python in VS Code
Let's build git-cat with Python
Run DHT22 with RasPi + Python
Are you still using Jupyter Notebook? Enjoy a comfortable Python life with Jupyter Life (.py) with VS Code ?!
Document Python code with Doxygen
Operate Jupyter with REST API to extract and save Python code
Let's summarize the degree of coupling between modules with Python code
Create a simple Python development environment with VS Code and Docker
Build jupyter notebook environment with Visual Studio Code (VS Code) Mac version
Let's run "python -m antigravity" in python
Let's make a GUI with python.
Run Rotrics DexArm with python API
Run mruby with Python or Blender
Run Tensorflow natively supported on windows
Let's play with Excel with Python [Beginner]
Run XGBoost with Cloud Dataflow (Python)
Run Aprili from Python with Orange
Run python3 Django1.9 with mod_wsgi (deploy)
Let's do image scraping with Python
Let's make a graph with python! !!
Until you run python with apache
Let's analyze voice with Python # 1 FFT
[VS Code] ~ Tips when using python ~
How to debug a Python program by remotely connecting to a Docker container in WSL2 environment with VS Code
Build a development environment using Jupyter and Flask with Python in Docker (supports both VS Code / code-server)
Prepare a Python virtual environment for your project with venv with VS Code
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
I was addicted to creating a Python venv environment with VS Code