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).
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.
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.
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
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
Omit. Edit the path in the same way as in 1 and revert to the version you want to use.
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