The following are all performed on my virtual machine
sudo apt install python3-pip
sudo apt install virtualenv
sudo apt install virtualenvwrapper
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
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