Create a Python virtual development environment on Windows

Introduction

I was researching various things because I wanted to use python on Windows, but I went back and forth when building the environment, so I will output it as a memorandum. Write the code in VS code.

environment

・ Windows 10 Home ・ Visual Studio Code

As a prerequisite, make sure that python itself is installed on Windows. You can install it from here. This is the official page of python japan.

Type a command

For Windows, open powershell as an administrator,

Set-ExecutionPolicy RemoteSigned

Type the command. This allows the script to run only on local files. There are other options, so if you are interested, please refer to here.

Then, in VScode's terminal, create and move the directory you want to work in.

$ mkdir test
$ cd test

Create a virtual environment directly under the test directory. Actually, this is the only place where I got stuck, but in my environment, when I typed the following command, it entered the virtual environment obediently.

$ py -m venv myenv
$ myenv/Scripts/Activate.ps1

Change "myenv" to any character string.

Depending on the site, py was python or python3, and there were a lot of commands lined up, and even if I typed it, it didn't work or I was angry.

Then, when I was looking at the python japan page, I was wondering why the py command works, and there was a description like this.

For the Windows version of Python, the Python launcher py is recommended over using the python command. Normally, when you run Python from the command line, you need to record the directory where you installed Python in a system setting called an environment variable, but py can be run without any settings.

If you want to use the python command, please pass the path in each environment, but is it okay to recognize that the py command can be used by default?

Anyway, if you type the above, you should see (myenv) on the left side of the terminal. You are now in the virtual environment.

By the way, the command to exit the virtual environment is

$ deactivate

is.

It is necessary to continue to make settings on the VScode side, but since some people have already written an article, please refer to here to make settings. The content is to run Django in a virtual environment, but I think that it is okay if you make the same settings for other frameworks.

Recommended Posts

Create a Python virtual development environment on Windows
[Venv] Create a python virtual environment on Ubuntu
Create a Python environment on Mac (2017/4)
Create a virtual environment with Python!
Create a python environment on centos
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a GVim-based Python development environment on Windows 10 (1) Installation
Create a decent shell and python environment on Windows
Create a Python development environment on OS X Lion
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Steps to create a Python virtual environment with VS Code on Windows
Create a python environment on your Mac
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Create a Python environment
Create a Linux virtual machine on Windows
Create a virtual environment for python on mac [Very easy]
Create a Python environment for professionals in VS Code on Windows
How to create a Python virtual environment (venv)
Simply build a Python 3 execution environment on Windows
Create a virtual environment with conda in Python
Build a Python development environment on your Mac
[Python] Web development preparation (building a virtual environment)
Set up a Python development environment on Marvericks
Create a Python execution environment on IBM i
Build a Python development environment on Raspberry Pi
Python + Kivy development on Windows
Build Python environment on Windows
Django environment development on Windows 10
Building a Python virtual environment
Build python environment on windows
Building a Python virtual environment
Notes on creating a python development environment on macOS Catalina
Build a Python development environment on Mac OS X
Procedure for building a CDK environment on Windows (Python)
Build a Python development environment using pyenv on MacOS
Building a Python environment on Mac
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Building a Python environment on Ubuntu
Install python2.7 on windows 32bit environment
[Python3] Development environment construction << Windows edition >>
Building a virtual environment with Python 3
Python development environment construction on macOS
Build a python3 environment on CentOS7
How to build a new python virtual environment on Ubuntu
Create a VS Code + Docker development environment on a Linux VM
Create a simple Python development environment with VSCode & Docker Desktop
Until building a Python development environment using pyenv on Ubuntu 20.04
Python on Windows
python windows environment
Until you create a machine learning environment with Python on Windows 7 and run it
Python 2.7, 3.4, 3.5 extension module build environment on Windows
Build a python environment on MacOS (Catallina)
Python virtual environment and packages on Ubuntu
Building a Python 3.6 environment with Windows + PowerShell
[Python] Create a Batch environment using AWS-CDK
Create a virtual environment with Python_Mac version
Create an OpenCV3 + python3 environment on OSX
Build a python virtual environment with pyenv