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 to use python virtual environment

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Editor to share with you how to use the python virtual environment, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

Virtualenv

Virtualenv is used to create an independent Python environment. Multiple Python are independent of each other and do not affect each other. It can:

Install a new suite without permission

Different applications can use different versions of the suite

Suite upgrade does not affect other applications

Install sudo apt-get install python-virtualenv usage virtualenv [Virtual Environment name]

For example, create a virtual environment of "ENV"

Virtualenv ENV

By default, the virtual environment depends on the site packages in the system environment, that is, the third-party package already installed in the system will also be installed in the virtual environment. If you do not want to rely on these package, you can add the parameter-no-site-packages to establish the virtual environment.

Virtualenv-- no-site-packages [Virtual Environment name] launches the virtual environment cd ENVsource. / bin/activate

Note that there will be one more ENV on the command line, ENV is the virtual environment name, and then all modules will only be installed in this directory.

Exit the virtual environment deactivate to install the Python suite

Virtualenv comes with the pip installation tool, so the packages you need to install can be run directly:

Pip install [package name]

If the virtual environment is not started and the pip tool is installed on the system, the suite will be installed in the system environment. To avoid this, add the following to the ~ / .bashrc file:

Export PIP_REQUIRE_VIRTUALENV=true

Or let the system open the virtual environment automatically when executing pip:

Export PIP_RESPECT_VIRTUALENV=true above is all the content of this article "how to use python Virtual Environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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