In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the value and commonly used commands of Python virtual environment". In daily operation, I believe that many people have doubts about the value and commonly used commands of Python virtual environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods, hoping to help you answer the doubts about "the value of Python virtual environment and commonly used commands". Next, please follow the editor to study!
Why is there a virtual environment?
In the actual project development, we usually download a variety of corresponding framework libraries according to our own needs, such as Scrapy, Beautiful Soup, etc., but each project may not use the same framework library, or use a different version of the framework.
This requires us to constantly update or uninstall the corresponding libraries according to the requirements.
Operating directly on our Python environment will cause a lot of unnecessary trouble and management confusion to our development environment and projects.
Such as the following scenarios:
Scenario 1: project A requires version 1.0 of a framework, and Project B requires version 2.0 of the library. If the virtual environment is not installed, then when you use these two projects, you need to uninstall the installation back and forth, which can easily bring inexplicable errors to your project.
Scenario 2: the previous project of the company needs to run in the python2.7 environment, while the project you take over needs to run in the python3 environment. You should know that if you don't use the virtual environment, these two projects may not be able to be used at the same time, and if you use python3, the company's previous project may not run, otherwise, the new project will have trouble running. If the virtual environment can configure different running environments for the two projects, so that the two projects can run at the same time.
Tips: as a matter of fact, there are many benefits of virtual environment, and you need to have some basic understanding of the relevant commands. I'll write it down here for follow-up reference.
View the existing virtual environment # enter the following command on the command line
Conda info-envs
Create a new virtual environment # enter the following command on the command line
Conda create-name newName python=3.7
When you create multiple virtual environments locally, coupled with the installation of different third-party package in different virtual environments, the switching of virtual environments is important.
Switch virtual environment # switch to the desired virtual environment on the command line, and here I switch to project-1
Conda activate project-1
You can then install the package in the current environment:
# install ipykernel in the current paddle environment
Conda install ipykernel
At this point, the study on "the value and common commands of Python virtual environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.