Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Ubuntu20.04 installs Python3's virtual environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how Ubuntu20.04 installs the virtual environment of Python3". The editor shows you the operation process through the actual case. The method of operation is simple, fast and practical. I hope that this article "how to install the virtual environment of Python3 in Ubuntu20.04" can help you solve the problem.

1. Install pip3

Sudo apt install python3-pip

two。 Install a virtual environment

Sudo apt install virtualenvsudo apt install virtualenvwrapper

3. 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

Among them, the sentence "usr/share/virtualenvwrapper/virtualenvwrapper.sh" is different from other ubuntu versions. Other bosses are "source / usr/local/bin/virtualenvwrapper.sh" on ubuntu18.04, and the specific file location can be found and filled 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 change the path you found.

Sudo find /-name virtualenvwrapper.sh

4. 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

Virtual environments are used to isolate python libraries between different projects

Create a virtual environment

Python3 has a built-in venv module. First create a project directory. After entering the directory, execute

Python3-m venv venv

Activate the virtual environment

Before you start working, activate the appropriate virtual environment:

. Venv/bin/activate

Under windows:

Venv\ scripts\ activate

When activated, your terminal prompt displays the name of the virtual environment.

Install the appropriate modules, such as:

Pip install flask

This is the end of the introduction to "how Ubuntu20.04 installs the virtual environment of Python3". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report