> For the complete documentation index, see [llms.txt](https://pythonforstarters.solomonmarvel.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pythonforstarters.solomonmarvel.com/virtual-environments/virtualenv.md).

# Virtualenv

`virtualenv` is a tool used to isolate specific Python environments on a single machine, allowing you to work with multiple versions of Python packages and libraries without conflicts. This can be useful if you need to work on multiple projects that require different versions of packages, or if you want to test your code on multiple versions of Python.

Here's how you can use `virtualenv`:

* Install `virtualenv`:

```bash
pip install virtualenv
```

* Create a new virtual environment:

```bash
virtualenv myenv
```

This will create a new directory called "myenv" that contains a copy of the Python interpreter and libraries, as well as a script called activate that you can use to activate the environment.

* Activate the virtual environment:

```bash
source myenv/bin/activate
```

This will modify your shell prompt to indicate that you are now working in the virtual environment. Your virtual environment will also be the default Python interpreter until you deactivate it.

* Install packages: With the virtual environment active, you can now install packages using pip as you normally would. These packages will be installed in the virtual environment, rather than globally on your system.

```bash
pip install <package-name>
```

* Deactivate the virtual environment: When you are finished working in the virtual environment, you can deactivate it by running the following command:

```bash
deactivate
```

This will restore the original Python interpreter and libraries, and remove the virtual environment from your shell prompt.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://pythonforstarters.solomonmarvel.com/virtual-environments/virtualenv.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
