In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to create a python virtual environment". In daily operation, I believe many people have doubts about how to create a python virtual environment. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to create a python virtual environment". Next, please follow the editor to study!
Pipenv workflow
Pipenv is a pip-based Python package management tool, and its usage is very similar to pip. It can be seen as an enhanced version of pip, and its emergence solves the disadvantages of the old pip+virtualenv+requirements.txt way of working. Specifically, it is a combination of pip, Pipfile and Virtualenv
1. Installation
View pip version
Pip-version
Install pipenv
Pip install pipenv
View version number
Pipenv-- version2. Create a virtual environment
In Python, a virtual environment (virtual enviroment) is an isolated Python interpreter environment. By creating a virtual environment, you can have a separate Python interpreter environment. Use the pipenv install command in the root directory to create a virtual environment for the current project.
By default, Pipenv uniformly manages all virtual environments.
On Windows systems, virtual environment folders are created in the C:\ Users\ Administrator.virtualenvs\ directory, while Linux or mac OS are created in the ~ / .local / share/virtualenvs/ directory. If you want to create a virtual environment folder within the project directory, you can set the environment variable PIPENV_VENV_IN_PROJECT, and a virtual environment folder named .venv will be created in the project root directory.
When using Virtualenv alone, we usually explicitly activate the virtual environment. In Pipenv, you can explicitly activate the virtual environment using the pipenv shell command, where Pipenv starts a child shell that activates the virtual environment, and now you will find that the virtual environment name "(virtual environment name) $" is added to the command line prompt.
3. Management dependence
When creating a virtual environment, if there is no Pipfile file in the root of the project, the pipenv install command also creates Pipfile and Pipfile.lock files in the root of the project folder, the former to record the list of project dependencies, and the latter to record a detailed list of dependent packages for the fixed version. When we use Pipenv to install / remove / update dependent packages, Pipfile and Pipfile. Lock updates automatically.
You can use the pipenv graph command to view dependencies in the current environment, or use the pip list command to view a list of dependencies in a virtual environment.
When you need to run the program in a new environment, you only need to execute the pipenv install command. Pipenv creates a new virtual environment, then automatically reads the dependencies from Pipfile and installs them into the newly created virtual environment.
4.pycharm sets up a virtual environment
Python3.8 virtual environment
At this point, the study on "how to create a 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.