I found a procedure to use Jupyter Notebook in Visual Studio Code and a procedure to use Jupyter Notebook in Mac, but I could not find a procedure in the environment that combines Windows 10 with Poetry and pyenv-win, so in this environment I summarized the procedure to use Jupyter Notebook from Visual Studio Code.
With Anaconda, you can easily use Jupyter Notebook, but one reason is that you haven't used Anaconda these days for religious reasons.
Python 3.8.5 + pyenv-win + Poetry is installed by the following procedure. Using Poetry and pyenv from Python installation on Windows 10 (https://qiita.com/kerobot/items/3f4064d5174676080585)
I have installed "Python" as an extension in Visual Studio Code. Python Extensions in Visual Studio Code
Use the Powershell gcm command to find the location of pyenv-win.
> gcm pyenv | fl
Check the version of pyenv-win.
> pyenv --version
pyenv 2.64.2
Use pyenv-win to set up Python in the global environment.
> pyenv versions
> pyenv install 3.8.5
> pyenv global 3.8.5
> pyenv rehash
> python -V
Python 3.8.5
Upgrade the configured Python pip.
> python -m pip install --upgrade pip
> pip -V
pip 20.3.3
Use Powershell's gcm command to find the location of Poetry.
> gcm poetry | fl
Check the version of Poetry.
> poetry --version
Poetry version 1.1.0
Create a project (project directory) using Poetry.
> poetry new jupyter
Go to the project you created.
> cd jupyter
Use pyenv-win to set up Python for your project's local environment.
> pyenv local 3.8.5
> pyenv rehash
> Python -V
Python 3.8.5
Build a Python virtual environment using Poetry.
> poetry install
Creating virtualenv jupyter in D:\Develop\Git\jupyter\.venv
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 10 installs, 0 updates, 0 removals
• Installing pyparsing (2.4.7)
• Installing atomicwrites (1.4.0)
• Installing attrs (20.3.0)
• Installing colorama (0.4.4)
• Installing more-itertools (8.6.0)
• Installing packaging (20.8)
• Installing pluggy (0.13.1)
• Installing py (1.10.0)
• Installing wcwidth (0.2.5)
• Installing pytest (5.4.3)
Installing the current project: jupyter (0.1.0)
Add the following packages.
> poetry add pylint
> poetry add numpy==1.19.3
> poetry add pandas
> poetry add ipykernel
For Windows 10 2004 (20H2), there is a problem with fmod as of December 2020, and when I run numpy 1.19.4 using it, I get an error. I am using 1.19.3 to avoid errors. fmod(), after an update to windows 2004, is causing a strange interaction with other code
Use Poetry to check the operation.
> poetry run python -V
Python 3.8.5
Install jupyter using pip instead of Poetry when the Python virtual environment is not enabled.
> pip install jupyter
When I installed it using Poetry, I could not install it due to the following assertion error, so I installed it using pip.
D:\Develop\Git\jupyter> poetry add jupyter
Using version ^1.0.0 for jupyter
Updating dependencies
Resolving dependencies...
AssertionError
at ~\.poetry\lib\poetry\mixology\incompatibility.py:111 in __str__
107│ )
108│
109│ def __str__(self):
110│ if isinstance(self._cause, DependencyCause):
→ 111│ assert len(self._terms) == 2
112│
113│ depender = self._terms[0]
114│ dependee = self._terms[1]
115│ assert depender.is_positive()
You will get a character code and PATH warning, but leave it as it is.
WARNING: Subprocess output does not appear to be encoded as cp932
...
WARNING: The scripts jupyter-migrate.exe, jupyter-troubleshoot.exe and jupyter.exe are installed in 'c:\users\user\.pyenv\pyenv-win\versions\3.8.5\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script jsonschema.exe is installed in 'c:\users\user\.pyenv\pyenv-win\versions\3.8.5\Scripts' which is not on PATH.
...
I think the character code warning is due to the change in the character code of pyenv-win from CP1250 to CP65001.
Launch Visual Studio Code in your project's directory.
> code .
Select the Python interpreter that Visual Studio Code will use.
Open the command palette with Ctrl + Shift + P, type python select interpreter, and select ".venv \ Scripts \ python.exe" as the Python interpreter environment.
Make sure that settings.json is created in your project's .vscode directory and has the following content:
{
"python.pythonPath": ".venv\\Scripts\\python.exe"
}
Create a notebook for use with Visual Studio Code.
Open the command palette with Ctrl + Shift + P, type jupyter create new, and select Jupyter: Create New Blank Jupyter Notebook to create a new notebook.
The Python virtual environment will automatically start and you will be able to use your notebook.
You can now run your Python script.
You can press Ctrl + Enter to execute a cell and Ctrl + Shift + Enter to insert a cell.
I stumbled upon the introduction of jupyter, but I was able to use Jupyter Notebook with Visual Studio Code on Windows 10.
It's nice to be able to edit and save notebooks with a familiar editor. Since it uses pyenv-win and Poetry, it seems easy to try the required version and package combination.