1
1
---
2
- title : How to set up a virtual environment
2
+ title : How to set up an environment
3
3
---
4
4
5
- In this guide we summarize some key commands to set up a virtual environment
6
- with different tools in the scientific python ecosystem.
7
- A virtual environment is a workspace into which you can install Python
5
+ In this guide we summarize some key commands to set up an environment
6
+ with different tools that you might encounter in the scientific python
7
+ ecosystem. An environment is a workspace into which you can install Python
8
8
libraries, separate from what is being used by your operating system.
9
9
10
10
The environment managers that are covered in this how-to guide include:
@@ -14,13 +14,16 @@ The environment managers that are covered in this how-to guide include:
14
14
- uv
15
15
- pixi
16
16
17
- In each of these examples we'll create a new virtual environment related to our project called ` science `
18
- (you can use whichever name you prefer!). We'll activate the environment, install some dependencies, and see
19
- an example of installing dependencies from a file.
17
+ In each of these examples we'll create a new virtual environment related to our
18
+ project called ` science ` (you can use whichever name you prefer!). We'll activate
19
+ the environment, install some dependencies, and see
20
+ an example of installing dependencies from an existing file. You may encounter
21
+ files like ` requirements.txt ` , ` environment.yml ` or ` pyproject.toml ` that specify
22
+ needed dependencies for a project.
20
23
21
24
### Set up a virtual environment with venv
22
25
23
- With venv we'll have our virtual environment associated with our project folder called ` science ` .
26
+ With venv to create environment associated with a project folder called ` science ` .
24
27
25
28
```
26
29
python -m venv science
@@ -52,6 +55,9 @@ Remember to re-activate your environment every time you open a new terminal, usi
52
55
source science/bin/activate
53
56
```
54
57
58
+ You can find more information on using venv for packaging
59
+ [ here] ( https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/ ) .
60
+
55
61
### Set up an environment using conda
56
62
57
63
With conda, we can create a new environment named science (-n is the same as passing --name):
@@ -87,6 +93,9 @@ Remember to re-activate your environment every time you open a new terminal:
87
93
conda activate science
88
94
```
89
95
96
+ You can find more information on using conda for environments
97
+ [ here] ( https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html ) .
98
+
90
99
### Set up an environment using mamba
91
100
92
101
With mamba, like conda, we can create a new environment named science (-n is the same as passing --name):
@@ -120,6 +129,9 @@ Remember to re-activate your environment every time you open a new terminal:
120
129
mamba activate science
121
130
```
122
131
132
+ You can find more information on using mamba in the
133
+ [ mamba user guide] ( https://mamba.readthedocs.io/en/latest/user_guide/mamba.html ) .
134
+
123
135
### Set up a virtual environment using uv
124
136
125
137
To create a new environment using uv in our project folder called ` science ` :
@@ -192,7 +204,7 @@ pixi shell --environment=<envname>
192
204
```
193
205
194
206
You can find more information on using pixi
195
- [ here] ( https://docs.astral.sh/uv/pip/environments/#creating-a-virtual-environment ) .
207
+ [ here] ( https://prefix.dev/docs/pixi/basic_usage ) .
196
208
197
209
198
210
0 commit comments