install virtualenv
时间: 2024-08-12 16:04:37 浏览: 37
virtualenv介绍及简明教程
To install `virtualenv`, you can follow these steps:
1. **Check if Python is installed**: Ensure that you have Python on your system. You can do this by opening a terminal or command prompt and running `python --version` or `python3 --version`.
2. **Install pip**: If you don't have `pip`, the package installer for Python, run the following commands to install it (assuming you have Python 3):
```shell
curl https://bootstrap.pypa.io/get-pip.py | python3
```
3. **Create a new environment**: Once `pip` is installed, use `virtualenv` to create a new virtual environment. Run the following command in your project directory where you want to set up the environment:
```shell
pip install virtualenv
```
Or, if you're using Python 2, use:
```shell
easy_install virtualenv
```
4. **Activate the environment**: After installation, activate the virtual environment by running the appropriate command for your platform:
- On Windows with PowerShell:
```shell
.\Scripts\activate
```
- On Windows with Command Prompt:
```shell
Scripts\activate
```
- On macOS/Linux with Bash shell:
```shell
source bin/activate
```
5. **Verify installation**: To ensure that the virtual environment is activated, type `which python`. It should show the path to the Python interpreter inside the virtual environment.
That's it! Now you have a separate environment isolated from your global Python installation, allowing you to manage different packages for different projects.
阅读全文