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

Apache Calcite code for dialect conversion

definition Calcite can unify Sql by parsing Sql i...

Several methods of deploying multiple front-end projects with nginx

I have summarized 3 methods to deploy multiple fr...

JavaScript implements select all and unselect all operations

This article shares the specific code for JavaScr...

SQL implementation of LeetCode (175. Joining two tables)

[LeetCode] 175.Combine Two Tables Table: Person +...

Summary of several commonly used CentOS7 images based on Docker

Table of contents 1 Install Docker 2 Configuring ...

Detailed tutorial on installing MySQL database on Alibaba Cloud Server

Table of contents Preface 1. Uninstall MySQL 2. I...

An example of how to implement an adaptive square using CSS

The traditional method is to write a square in a ...

Share 8 very useful CSS development tools

CSS3 Patterns Gallery This CSS3 pattern library s...

What are the drawbacks of deploying the database in a Docker container?

Preface Docker has been very popular in the past ...

Analysis of the implementation process of three modes of VMWare network adapter

Three modes Bridged (bridge mode), NAT (network a...

How to introduce scss into react project

First download the dependencies yarn add sass-loa...

VMware vSphere 6.7 (ESXI 6.7) graphic installation steps

Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...

MySQL 5.7.18 free installation version configuration tutorial

MySQL 5.7.18 free installation version installati...

Steps to configure nginx ssl to implement https access (suitable for novices)

Preface After deploying the server, I visited my ...