@@ -25,33 +25,33 @@ needed dependencies for a project.
25
25
26
26
With venv to create environment associated with a project folder called ` science ` .
27
27
28
- ```
28
+ ``` shell
29
29
python -m venv science
30
30
```
31
31
32
32
Start using it by activating it as follows:
33
33
34
- ```
34
+ ``` shell
35
35
source science/bin/activate
36
36
```
37
37
38
38
You are now ready to install Scientific Python packages using ` pip ` ! For example:
39
39
40
- ```
40
+ ``` shell
41
41
pip install ipython numpy scipy
42
42
```
43
43
44
44
Often you'll interact with projects that have a specific list of dependencies (for development
45
45
environments, testing environments, or the project itself). You can install the list of dependencies
46
46
with pip in your venv using:
47
47
48
- ```
48
+ ``` shell
49
49
pip install -r < path/to/requirements.txt>
50
50
```
51
51
52
52
Remember to re-activate your environment every time you open a new terminal, using:
53
53
54
- ```
54
+ ``` shell
55
55
source science/bin/activate
56
56
```
57
57
@@ -62,34 +62,34 @@ You can find more information on using venv for packaging
62
62
63
63
With conda, we can create a new environment named science (-n is the same as passing --name):
64
64
65
- ```
65
+ ``` shell
66
66
conda create -n science
67
67
```
68
68
69
69
Start using your environment by activating it:
70
70
71
- ```
71
+ ``` shell
72
72
conda activate science
73
73
```
74
74
75
75
You are now ready to install Scientific Python packages using ` conda ` !
76
76
For example:
77
77
78
- ```
78
+ ``` shell
79
79
conda install ipython numpy scipy
80
80
```
81
81
82
82
Some projects distribute environment files with listed dependencies with an ` environment.yml ` file.
83
83
The first line of this file sets the environment's name. To
84
84
create an environment and install the dependencies with this file, use:
85
85
86
- ```
86
+ ``` shell
87
87
conda env create -f < path/to/environment.yml>
88
88
```
89
89
90
90
Remember to re-activate your environment every time you open a new terminal:
91
91
92
- ```
92
+ ``` shell
93
93
conda activate science
94
94
```
95
95
@@ -100,32 +100,32 @@ You can find more information on using conda for environments
100
100
101
101
With mamba, like conda, we can create a new environment named science (-n is the same as passing --name):
102
102
103
- ```
103
+ ``` shell
104
104
mamba create -n science
105
105
```
106
106
107
107
Start using your environment by activating it:
108
108
109
- ```
109
+ ``` shell
110
110
mamba activate science
111
111
```
112
112
113
113
You are now ready to install Scientific Python packages using ` mamba ` !
114
114
For example:
115
115
116
- ```
116
+ ``` shell
117
117
mamba install ipython numpy scipy
118
118
```
119
119
120
120
To install a specific environment from a ` .yml ` file, use:
121
121
122
- ```
122
+ ``` shell
123
123
mamba create -f < /path/to/environment.yml>
124
124
```
125
125
126
126
Remember to re-activate your environment every time you open a new terminal:
127
127
128
- ```
128
+ ``` shell
129
129
mamba activate science
130
130
```
131
131
@@ -134,34 +134,35 @@ You can find more information on using mamba in the
134
134
135
135
### Set up a virtual environment using uv
136
136
137
- To create a new environment using uv in our project folder called ` science ` :
137
+ To create a new environment using uv in a project folder called ` science ` ,
138
+ navigate to that folder and execute:
138
139
139
- ```
140
+ ``` shell
140
141
uv venv
141
142
```
142
143
143
144
Start using your environment by activating it:
144
145
145
- ```
146
+ ``` shell
146
147
source .venv/bin/activate
147
148
```
148
149
149
150
You are now ready to install Scientific Python packages using ` uv ` !
150
151
For example:
151
152
152
- ```
153
+ ``` shell
153
154
uv pip install ipython numpy scipy
154
155
```
155
156
156
157
To install dependencies from a requirements file, use:
157
158
158
- ```
159
+ ``` shell
159
160
uv pip install -f < /path/to/requirements.txt>
160
161
```
161
162
162
163
Remember to re-activate your environment time you open a new terminal:
163
164
164
- ```
165
+ ``` shell
165
166
source < path/to/science/> .venv/bin/activate
166
167
```
167
168
@@ -172,34 +173,37 @@ You can find more information on using uv for environments
172
173
173
174
To initialize a new project with pixi in our project called ` science ` , execute:
174
175
175
- ```
176
+ ``` shell
176
177
pixi init
177
178
```
178
179
179
180
You are now ready to install Scientific Python packages as dependencies in this project!
180
181
From the science directory, execute:
181
182
182
- ```
183
+ ``` shell
183
184
pixi add ipython numpy scipy
184
185
```
185
186
186
187
To install dependencies from a file like ` environment.yml ` , use:
187
188
188
- ```
189
+ ``` shell
189
190
pixi init --import < path/to/environment.yml>
190
191
```
191
192
192
193
Remember to re-activate your environment when you re-open a terminal. Navigate to
193
194
the science folder, and execute:
194
195
195
- ```
196
+ ``` shell
196
197
pixi shell
197
198
```
198
199
200
+ This will drop you into the default environment for the pixi project, with all
201
+ dependencies in that environment accessible to you in that shell.
202
+
199
203
A pixi project may have multiple environments defined in the ` pixi.toml ` file. To
200
204
load a specific environment:
201
205
202
- ```
206
+ ``` shell
203
207
pixi shell --environment=< envname>
204
208
```
205
209
0 commit comments