I will explain how to create a ** python virtual environment ** using venv on Ubuntu. There are several commands to create a virtual environment, but this time I will talk about ** venv **, which can be created quickly.
** For those who are creating a python virtual environment for the first time **, ** For those who want to create it quickly for the time being **, ** For those who have forgotten how to create it ** I hope it will be helpful.
The installation of Ubuntu is omitted. (Refer to the reference site for installation)
You can check the version of python3 installed with python3 -V
.
After entering this, when the version is displayed, python3 is already installed.
If python3 is not installed, please refer to the following web page to install it.
Python in Ubuntu environment
According to this page ** It is better not to mess with the default python3 so much, it seems better to install python3 separately. ** It was my first time hearing. .. ..
You can create a virtual environment named ** yourvenv ** with python3 -m venv your venv
.
If you want to change the environment name, change yourvenv to any name.
Please note that just creating it ** is not yet in the virtual environment **.
Enter source ./yourvenv/bin/activate
to enter the virtual environment.
If you see (yourvenv) on the left, you are in a virtual environment. (Myvenv in the figure)
You can deactivate the virtual environment with deactivate
.
deactivate
only deactivates the virtual environment, not ** the environment itself. ** **
So if you want to re-enter the virtual environment, you can re-enter with source ./yourvenv/bin/activate
.
If there is no (yourvenv) on the left side, you are back to the original environment.
List the installed packages by running python3 -m pip freeze
in the virtual environment.
What you see here is the virtual environment package, which is different from the original environment package.
As usual, you can install it with python3 -m pip install package -name
.
-venv: Python Virtual Environment Management -pyenv, pyenv-virtualenv, venv, Anaconda, Pipenv. I use Pipenv.
[[Windows10 + Ubuntu20.04 + VSCode] Run Ubuntu20.04 on WSL2 with VSCode on Windows](https://tkmt-hrkz.hatenablog.com/entry/2020/07/17/%E3%80% 90Windows10% 2BUbuntu20_04% 2BVSCode% E3% 80% 91WSL2% E4% B8% 8A% E3% 81% AEUbuntu20_04% E3% 82% 92Windows% E4% B8% 8A% E3% 81% AEVSCode% E3% 81% A7% E5% 8B% 95% E3% 81% 8B% E3% 81% 99)
Recommended Posts