Install Python virtual environment in Ubuntu 18.04

Install Python virtual environment in Ubuntu 18.04

For reference only for Python developers using Ubuntu 18.04

1. Install Ubuntu 18.04 virtual environment

sudo apt install virtualenv
sudo apt install virtualenvwrapper

After the installation is complete, go to the home directory and enter the ls -al command to check whether the .virtualenvs directory appears. If not, manually create the .virtualenvs directory.

2. Install the module that can support virtual environment in Python environment (I use Python 3.6 here)

pip3 install virtualenv
pip3 install virtualenvwrapper

3. Configure the virtual management directory

Enter the home directory, enter the command ls -al, find the .bashrc file, and modify the .bashrc file

Add two lines to the end of your .bashrc file:

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

4. Enable the configuration file

source ~/.bashrc

5. Check whether a virtual environment can be created

Use the mkvirtualenv project name to create a virtual environment. If successful, it means that the Ubuntu 18.04 virtual environment has been successfully created.

PS: Let's take a look at Ubuntu 18.04 installation & creation of virtual environment

1. Install and configure the virtual environment

Installing a Virtual Environment

sudo apt install virtualenv
sudo apt install virtualenvwrapper

Configure the virtual management directory (in the home directory, press ctrl + h to open the hidden file and you can see .bashrc)

1. Create a directory to store the virtual environment

 mkdir $HOME/.virtualenvs

2. Add the following line to ~/.bashrc:

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

2. Enable the configuration file

source ~/.bashrc

Summarize

The above is the introduction of the Python virtual environment installed in Ubuntu 18.04. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed explanation of Python configuration virtual environment
  • Summary of Python's methods for creating virtual environments
  • Python development preparation: configuring a virtual environment (very important)
  • Python virtual environment migration method
  • How to install Python3 and create a virtual environment under CentOS
  • Python configuration virtual environment graphic steps

<<:  Detailed explanation of mysql partition function and example analysis

>>:  Detailed explanation of vite+ts to quickly build vue3 projects and introduce related features

Recommend

Solution for adding iptables firewall policy to MySQL service

If your MySQL database is installed on a centos7 ...

Tutorial on installing mongodb under linux

MongoDB is cross-platform and can be installed on...

mysql 5.7.23 winx64 decompression version installation tutorial

Detailed installation tutorial of mysql-5.7.23-wi...

Two ways to completely delete users under Linux

Linux Operation Experimental environment: Centos7...

Notes on element's form components

Element form and code display For details, please...

Use CSS to set the width of INPUT in TD

Recently, when I was using C# to make a Web progra...

Solution to Ubuntu not being able to connect to the Internet

Problem description: I used a desktop computer an...

Basic tutorial on controlling Turtlebot3 mobile robot with ROS

Chinese Tutorial https://www.ncnynl.com/category/...

Shorten the page rendering time to make the page run faster

How to shorten the page rendering time on the bro...

Vue implements simple production of counter

This article example shares the simple implementa...

Implementation of sharing data between Docker Volume containers

What is volume? Volume means capacity in English,...

Calculation of percentage value when the css position property is absolute

When position is absolute, the percentage of its ...

Mysql: The user specified as a definer ('xxx@'%') does not exist solution

During the project optimization today, MySQL had ...

Chinese website user experience rankings

<br />User experience is increasingly valued...