linux virtualenvwrapper
时间: 2023-10-15 22:24:55 浏览: 109
Virtualenvwrapper is a tool that simplifies the management of Python virtual environments in Linux. It provides a set of commands to create, activate, and delete virtual environments, making it easier to work with different Python projects with their own dependencies.
To use Virtualenvwrapper, you need to have Python and Virtualenv installed on your system. Here are the steps to set up Virtualenvwrapper on Linux:
1. Install Virtualenv:
```
$ pip install virtualenv
```
2. Install Virtualenvwrapper:
```
$ pip install virtualenvwrapper
```
3. Add the following lines to your shell startup file (e.g., `~/.bashrc` or `~/.bash_profile`):
```
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 # Path to your Python interpreter
export WORKON_HOME=~/.virtualenvs # Directory to store virtual environments
source /usr/local/bin/virtualenvwrapper.sh # Path to virtualenvwrapper.sh
```
4. Reload the shell startup file:
```
$ source ~/.bashrc
```
5. Create a virtual environment:
```
$ mkvirtualenv myenv
```
6. Activate the virtual environment:
```
$ workon myenv
```
Now you can install Python packages within the virtual environment without affecting your system-wide Python installation. You can also switch between different virtual environments using the `workon` command.
Remember, Virtualenvwrapper is just a wrapper around Virtualenv, so it uses the same underlying mechanisms for creating and managing virtual environments. It provides additional convenience commands and organizes virtual environments in a more structured way.
阅读全文