Ubuntu20.04 install Python3 virtual environment tutorial detailed explanation

The following are all performed on my virtual machine

  1. Install pip3

sudo apt install python3-pip

  1. Install virtual environment
sudo apt install virtualenv
sudo apt install virtualenvwrapper
  1. Modify the configuration file to set environment variables

cd ~
vim .bashrc

Add the following two lines after the .bashrc file

export WORKON_HOME=$HOME/.virtualenvs 
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh 

The sentence "usr/share/virtualenvwrapper/virtualenvwrapper.sh" is different from other Ubuntu versions. For example, on Ubuntu 18.04, it is "source /usr/local/bin/virtualenvwrapper.sh". The specific file location can be Find it yourself and fill in
Tip: If you can't find virtualenvwrapper.sh, you can use the following command to find the path where the file is located, and replace the found path.

sudo find /-name virtualenvwrapper.sh
  1. Enable profile
source .bashrc

At this point, the virtual environment can be created normally.

PS: Let’s take a look at Python3 to create a virtual environment

purpose

The virtual environment is used to isolate Python libraries between different projects

Create a virtual environment

Python3 has built-in venv module, first create the project directory, after entering the directory, execute

python3 -m venv venv

Activate the virtual environment

Before starting work, first activate the corresponding virtual environment:

. venv/bin/activate

Under Windows:

venv\Scripts\activate

After activation, your terminal prompt will display the name of the virtual environment.

Install the corresponding modules, such as:

pip install Flask

to sum up

So far, this article about the virtual environment of installing Python3 on Ubuntu 20.04 is introduced. For more information about the virtual environment of installing Python 3 on Ubuntu 20.04, please search for previous articles of ZaLou.Cn or continue to browse the related articles below. Hope you all Support ZaLou.Cn a lot in the future!

Recommended Posts

Ubuntu20.04 install Python3 virtual environment tutorial detailed explanation
Install Python virtual environment on Ubuntu 18.04
Python virtual environment: Ubuntu16.04
ubuntu18.04 install python2
ubuntu12.04 install python3
ubuntu18.04 install python
Detailed tutorial on installing python3.7 for ubuntu18
Detailed usage of Python virtual environment venv
Windows10 install ubuntu20.04 dual system detailed graphic tutorial
Install python3.6 under Ubuntu 16.04
Python3 development environment to build a detailed tutorial
How to install python in ubuntu server environment
Ubuntu16.04 install Mongodb tutorial
Install Python3 on Ubuntu 14.04
Install Python3 environment in a brand new Ubuntu
Install python in Ubuntu
Install Python3 on Ubuntu 16.04
Install Python3.7 on Ubuntu
ubuntu14.04 install jdk1.8 tutorial
How to create a Python virtual environment in Ubuntu 14.04
Install ubuntu on virtual machine
Ubuntu install the latest Python 3.
Install python environment under Linux
Install Python 3.7 on Ubuntu 18.04 LTS
ubuntu sets python2.5 environment variables
ubuntu18.04 compile and install python3.8
ubuntu14.0464 Ros environment install halcon13.01
Virtual machine VirtualBox-5.1 install ubuntu16.0.1
vmware install CentOS 7 detailed tutorial
ubuntu build python development environment
Centos7 deploys python3 virtual environment
ubuntu offline installation python environment
Detailed steps for installing Django under Python 3.6 in Ubuntu 16.04 environment
Detailed explanation of python backtracking template
Virtual machine Linux Ubuntu installation tutorial
Detailed explanation of python sequence types
Detailed explanation of ubuntu using gpg2
Docker ubuntu: install python-PIL-image environment on 14.04
Python error handling assert detailed explanation
How to install Python 3.8 on Ubuntu 18.04
Install MySQL under Ubuntu 18.04 (graphic tutorial)
Install TensorFlow (python2.7 version) on Ubuntu
Install Spark stand-alone environment on Spark Ubuntu18
[python] python virtual environment construction & GPU environment
Install Hadoop system environment on Ubuntu 18.04
Detailed explanation of the installation and use of SSH in the Ubuntu environment
Install the latest Python 3.6 version on Ubuntu
Detailed explanation of Python IO port multiplexing
Build arm virtual operating environment on Ubuntu
Python from attribute to property detailed explanation
Install Ubuntu 18.04 in the virtual machine VMware
Ubuntu20.04 steps to install cuda10.1 (graphic tutorial)
Detailed tutorial for installing CUDA9.0 on Ubuntu 16.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
Detailed tutorial for installing phpMyAdmin on Ubuntu 18.04
Ubuntu18.04 install Nvidia graphics driver tutorial (graphic)
Vagrant quickly builds Ubuntu virtual machine environment
Use python3 to install third on ubuntu
Build a python development environment under Ubuntu
Install R package on UBUNTU virtual machine
Detailed explanation of -u parameter of python command