How to manage Python minor version (build virtual environment) on Windows (without Pyenv or WSL)

I want to manage the version even on Windows!

Anyone can think of it, but it's a method of reverting the Python version to the version for the virtual environment, creating a virtual environment, and then reverting. I made this article because I was confused by pyenv when I searched in a virtual environment, and I didn't know how to build a virtual environment for an older version of Python with venv.

Many people think that "I should use Anaconda Navigator of Anaconda", but in my anaconda environment, when I start jupyter, I get an error that "_Contextvars folder" does not exist, so I checked how much However, I couldn't find a solution, so I decided to manage the minor version by the method introduced this time (the method that does not use Anaconda).

Background

The version of python installed on the PC I always use was 3.8.1. However, in order to start the practical work, it was necessary to build a virtual environment of version 3.6.6.

With py -3 <what you want to do>, with python3 series I knew that with py -2 <what I want to do>, I could manage the version of python2.

However, as mentioned above, until managing minor versions such as 3.6 and 3.8, I had no choice but to use pyenv (as far as I can see).

So, I tried version control with pyenv using WSL, but it was troublesome to start Ubuntu. Also, in order to use Python managed by pyenv in my favorite IDE: Pycharm, there were still many steps such as securing an ssh connection to the daemon server every time Ubuntu was started (Reference: PyCharm +). Django development on Windows 10 with WSL)

I wondered if python version control could be done easily without any troublesome operations.

Method

Download Python 3.8 and 3.6

I will omit the explanation. At least 3.8 and 3.6 were installed together and there was no problem. For the version to be installed for the second time, make sure that the setting for passing the path is turned off.

Venv with Python 3.6

1: Change Path to the version you want to build a virtual environment

Start button ↓ Search and execute with "View advanced system settings" ↓ Environment variables (N ...) ↓ Double-click Path in the upper column (user environment variable) ↓ The default installation destination for python (in my case, below), C: \ Users \ {{username}} \ AppData \ Local \ Programs \ Python \ Python38 \ Scripts \ When C: \ Users \ {{username}} \ AppData \ Local \ Programs \ Python \ Python38 \ I think that is in the path, so change this Python38 toPython <version of the virtual environment you want to build>. In my case, I changed it to Python36. ↓ Decisive hit

2: Build a virtual environment with venv

Enter Python at the command prompt. Check the version and confirm that it matches ↓ Use cd <target Path> to move to the location where you want to build a virtual environment. ↓

command prompt


Python -m venv <Virtual environment name>

Create a virtual environment with ↓

command prompt


Virtual environment name/Scripts/activate

Start the virtual environment with and check

3: Return Path

Omit. Edit the path in the same way as in 1 and revert to the version you want to use.

For those who use Pycharm

File ↓ Settings ↓ Project Interpreter Therefore, if you set the interpreter path of the project to the path of the virtual environment you built, the virtual environment will be accessed automatically when the project is started. If you set the interpreter for each project in this way, it will be easier to manage minor versions, so if you are using Pycharm, please set it.

Recommended Posts

How to manage Python minor version (build virtual environment) on Windows (without Pyenv or WSL)
How to build a new python virtual environment on Ubuntu
Build a simple Python virtual environment without pyenv
How to build a Django (python) environment on docker
Build python environment on windows
How to build a Python environment on amazon linux 2
How to rebuild python environment from pyenv on Mac environment (El Capitan)
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
[Kivy] How to install Kivy on Windows [Python]
Creating a python virtual environment on Windows
Build a python virtual environment with pyenv
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
Steps to create a Python virtual environment with VS Code on Windows
Try to build python and anaconda environment on Mac (by pyenv, conda)
How to create a Python virtual environment (venv)
[2020 version] How to install Python3 on AWS EC2
Build python environment with pyenv on EC2 (ubuntu)
Simply build a Python 3 execution environment on Windows
[Latest] How to build Java environment on Ubuntu
[Python] How to install OpenCV on Anaconda [Windows]
How to build Java environment on Ubuntu (Linux)
Create a Python virtual development environment on Windows
I want to use Python in the environment of pyenv + pipenv on Windows 10
How to build an environment for using multiple versions of Python on Mac
How to run GUI programs such as tkinter in Python environment on WSL2
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
How to set up a Python environment using pyenv
How to embed mod_wsgi into Apache on Python Windows
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build a Python environment on your Mac using pyenv
Build a Python development environment using pyenv on MacOS
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
How to install Python [Windows]
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
Introducing Kaggle's Docker Image on Windows to build an environment
A note on how to load a virtual environment in PyCharm
How to develop in a virtual environment of Python [Memo]
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
How to build a python2.7 series development environment with Vagrant
How to change Python version
pyenv, virtualenv Use docker to manage the environment without using
[Sakura Rental Server] (For beginners) How to build an environment for Python, pyenv, and Flask. | For csh
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
Overview of Python virtual environment and how to create it
Example of building python development environment on windows (wsl2, vscode, pipenv)
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
How to write code to access python dashDB on Bluemix or local
How to use Serverless Framework & Python environment variables and manage stages
How to use python put in pyenv on macOS with PyCall
How to update the python version of Cloud Shell on GCP
How to set up the development environment of ev3dev [Windows version]
Shell script to build pyenv environment on ubuntu in one shot
How to build Python and Jupyter execution environment with VS Code
Everything from building a Python environment to running it on Windows
Virtual Environment Version Control Summary Python
Python environment construction memo on Windows 10
Python 3.6 on Windows ... and to Xamarin.