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

Virtualenv for python multi-environment extension

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

There are many versions of python, and the functions of each version are quite different. In the process of using, we often encounter inconsistencies between the python version that the third-party library depends on and the version of the system. At the same time, because the bottom layer of the system needs to call the current version of python, we cannot change the python version of the system at will. In this case, multiple python versions will coexist.

So python multi-environment management tools came into being, virtualenv and Pyenv. Both Pyenv and virtualenv are python management tools, but the difference is that the former manages the version of python to switch and use different versions, while the latter chooses the market to separate the system environment and other python environments from each other by creating a virtual environment.

(1) deployment

Step 1: install the python-pip and pythondevel packages

Shell > yum install python-pip python-devel-y

Step 2: check the installation environment

/ / make sure that development environment packages such as gcc glibc are installed on the server

Shell > yum install gcc glibc-devel zlib-devel rpm-build openssl-devel-y

/ / Update pip to the latest version

Shell > pip install-- upgrde pip

Step 3: install virtualenv

Shell > pip install virtualenv

Shell > virtualenv-- version # indicates successful installation

16.7.7

(2) use

Shell > virtualenv-- help

Usage: introduction to virtualenv [OPTIONS] DEST_DIR # syntax

Step 1: create a virtual directory

Shell > virtualenv / python/python3.6.6

Step 2: create a virtual working directory

Shell > virtualenv / python/data/sof/virtualpy/

Step 3: load the environment variables through source to change the local environment to the virtual working directory

Shell > virtualenv / python/data/sof/virtualpy/bin/activate

(virtualpy) [root@oy ~] # # switched successfully, not already entered the virtual working directory

Shell > deactivate exit the virtual environment directory

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

Servers

Wechat

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

12
Report