I'm new to Python. As the title suggests, when running Python on Windows, I settled on the environment with VS Code through various trials and errors, so I will record the procedure. The OS is windows10.
Python
> Downloads
> Windows
.Windows x86-64 executable installer
from among multiple installer types.In this article, I downloaded 3.8.2
.
** Install Python **
Windows
ʻUser Installer` and download.In this article, I downloaded 64bit
.
** Install VS Code **
Next, we will create a virtual environment.
Ctrl
+ Shift
+ X
to display the extensionJapanese Language Pack for Visual Studio Code
After this, I will explain that the VS Code menu is in Japanese.
2-1-2. Python
Ctrl
+ Shift
+ X
to display the extensionPython
Microsoft
extension (probably the first one listed)This is an extension for running Python on VS Code.
Here, it is described as the procedure to create the following document structure on a Windows PC.
C:\Users\\[user]\Documents\Python\dev01
(The [user]
part is the user name)
Python
We will prepare a folder called dev01 under this, but please do not create it yet. From here, we will operate on VS Code.
File
> Open Folder
Python
folder you created earlierIn this, we will create a virtual environment called dev01
.
Display
> Terminal
powershell
".Powershell is a Windows tool that operates with commands. You can manipulate this from VS Code.
On the last line of the terminal screen
PS C:\Users\\[user]\Documents\Python >
There is a character string called. After this, enter the command.
python -m venv dev01
and ʻEnter`dev01
is created.It is OK if you can see the following folders under dev01 in Explorer.
I have just created a Python virtual environment with a command called venv.
It feels like I created scripts and libraries to run Python in a folder called dev01
.
Although it is set to dev01
, it is assumed that another environment such as dev02
and dev03
will be created if necessary.
I don't know if there is a fixed procedure for setting the environment, Make the necessary settings while actually creating a Python file (.py) on a random basis.
File
> New File
in VS Codework_00_hello.py
print('Hello World!')
Ctrl
+ S
dev01
.work_00_hello.py
..py
, it will be recognized as a Python file even on VS Code, and a message prompting you to install the extension will be displayed, so install them.3-2-1. pylint
Linter pylint is not installed.
". You should consider upgrading via the'python -m pip install --upgrade pip' command.
".Terminal
> Python
python -m pip install --upgrade pip
and ʻEnter`The interpreter is a mechanism that allows you to translate and execute Python code.
I use an interpreter called python.exe, which sometimes exists in multiple directories.
Of the multiple Python.exe, set the meaning of specify Python.exe in the dev01 environment
.
Ctrl
+ Shift
+ P
to display the command paletteselect
in the box that appears and press ʻEnter`Python 3. \ *. \ * 64-bit ('dev01': venv)
The interpreter for the dev01 environment you just created is now selected.
The current environment is displayed at the bottom left of VS Code.
Python 3.*.* 64-bit ('dev01':venv)
Is displayed, it is OK.
Now, I think that a folder called PYTHON
is opened on VS Code Explorer.
Save this state as a workspace.
File
>Save workspace as
Document
> Python
Python
.Python.code-workspace
is saved in the Python folder.This completes the environment settings.
Hello World! Let's move the first Python file we created earlier.
Open work_00_hello.py
from Explorer
Press the play button
at the top right of the editor (the open Python file will be executed)
When "Hello World!
" Is displayed in the terminal, it is OK.
With the above, the virtual environment of Python is completed with VS Code of Windows. I've tried it several times, but it may be a different procedure depending on the environment and version.
Thank you very much.
Qiita About python environment preparation (python3 + vscode)
@markIT Visual Studio Code Settings "Cheat Sheet": Python Edition What you need to do to Python with VS Code
visualstudiocode Getting Started with Python in VS Code
python venv --- Create Virtual Environment
Recommended Posts