[Venv] Create a python virtual environment on Ubuntu

Introduction

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.

environment

Installation confirmation of python3

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. 1.png 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. .. ..

Create a python virtual environment

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.

Start a virtual environment

Please note that just creating it ** is not yet in the virtual environment **. Enter source ./yourvenv/bin/activate to enter the virtual environment. 2.png If you see (yourvenv) on the left, you are in a virtual environment. (Myvenv in the figure)

Exit the virtual environment

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.

Supplement

Check the python package for the virtual 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.

Install the package in a virtual environment

As usual, you can install it with python3 -m pip install package -name.

Reference site

-venv: Python Virtual Environment Management -pyenv, pyenv-virtualenv, venv, Anaconda, Pipenv. I use Pipenv.

Install and run Ubuntu

[[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

[Venv] Create a python virtual environment on Ubuntu
How to create a Python virtual environment (venv)
Create a Python virtual development environment on Windows
Building a Python environment on Ubuntu
Create a virtual environment with Python!
Create a python environment on centos
How to build a new python virtual environment on Ubuntu
Create a python environment on your Mac
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Creating a python virtual environment on Windows
Create a Python environment
Create a virtual environment for python on mac [Very easy]
Ubuntu18.04.05 Creating a python virtual environment in LTS
Create a virtual environment with conda in Python
Create a Python execution environment on IBM i
Building a Python virtual environment
venv: Python virtual environment management
python standard virtual environment venv
Building a Python virtual environment
Steps to create a Python virtual environment with VS Code on Windows
Python: Creating a virtual environment (venv), starting and stopping
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Create a comfortable Python 3 (Anaconda) development environment on windows
I made a Python3 environment on Ubuntu with direnv.
Build a Python virtual environment using venv (Django + MySQL ①)
Building and enabling a python virtual environment, etc. (venv)
Create a decent shell and python environment on Windows
Create a Python development environment on OS X Lion
Building a Python environment on Mac
Prepare Python development environment on Ubuntu
Create a Linux environment on Windows 10
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Build a python3 environment on CentOS7
OpenCV3 & Python3 environment construction on Ubuntu
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Until building a Python development environment using pyenv on Ubuntu 20.04
Create a web application execution environment of Python3.4 + Nginx + uWSGI + Flask with haste using venv on Ubuntu 14.04 LTS
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a python environment on MacOS (Catallina)
[Python] Create a Batch environment using AWS-CDK
Steps to install Python environment on Ubuntu
[Mac] Building a virtual environment for Python
Create a virtual environment with Python_Mac version
Created Ubuntu, Python, OpenCV environment on Docker
Create an OpenCV3 + python3 environment on OSX
Create a Linux virtual machine on Windows
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Add a Python virtual environment to VSCode
Create a Python environment for professionals in VS Code on Windows
# 3 Build a Python (Django) environment on AWS EC2 instance (ubuntu18.04) part2
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Create a USB boot Ubuntu with a Python environment for data analysis
Create a Vim + Python test environment in 1 minute
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Create a Python module
Simply build a Python 3 execution environment on Windows
Install python package in personal environment on Ubuntu
Build a Python environment on Mac (Mountain Lion)