How to create a virtual environment with pipenv

DDD
Release: 2023-11-23 15:33:07
Original
1533 people have browsed it

Pipenv Steps to create a virtual environment: 1. Make sure pipenv is installed; 2. Open a terminal or command line interface and navigate to the project directory; 3. Run the "pipenv --venv" command in the project directory to create a virtual environment; 4. Activate the virtual environment. After activation, you will see the command line prompt prefix with "venv" added; 5. The virtual environment is successfully created and activated, and the dependencies of the project can be installed and managed in it; 6. When you have finished your work and want to exit the virtual environment, you can run the "deactivate" command.

How to create a virtual environment with pipenv

Operating system for this tutorial: Windows 10 system, Python version 3.11.4, Dell G3 computer.

pipenv is a Python dependency management tool that can help developers manage project dependencies and create virtual environments to isolate the dependencies of different projects. The following are the steps to create a virtual environment using pipenv:

1. Make sure pipenv is installed. If it is not installed, you can install it using the following command:

pip install pipenv
Copy after login

2. Open a terminal or command line interface and navigate to your project directory.

3. Run the following command in the project directory to create a virtual environment:

pipenv --venv
Copy after login

After running this command, pipenv will create a file named .venv directory that contains all the dependencies of the virtual environment.

4. Now you can activate the virtual environment. On Windows, run the following command:

venv\Scripts\activate.bat
Copy after login

On macOS and Linux, run the following command:

source venv/bin/activate
Copy after login

Once you activate the virtual environment, you will see the command line prompt prefix increase (venv), indicating that a virtual environment is currently being used.

5. Now that you have successfully created and activated your virtual environment, you can install and manage your project's dependencies. For example, use the following command to install dependencies:

pipenv install <package-name>
Copy after login

6. When you have finished your work and want to exit the virtual environment , you can run the following command:

deactivate
Copy after login

This will exit the virtual environment and return to the system's default Python environment.

The above is the detailed content of How to create a virtual environment with pipenv. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template