Skip to content

Commit 3052c7d

Browse files
committed
add shell highlighting for environment commands
1 parent f801bbb commit 3052c7d

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

content/how-tos/how-to-create-environments.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,33 @@ needed dependencies for a project.
2525

2626
With venv to create environment associated with a project folder called `science`.
2727

28-
```
28+
```shell
2929
python -m venv science
3030
```
3131

3232
Start using it by activating it as follows:
3333

34-
```
34+
```shell
3535
source science/bin/activate
3636
```
3737

3838
You are now ready to install Scientific Python packages using `pip`! For example:
3939

40-
```
40+
```shell
4141
pip install ipython numpy scipy
4242
```
4343

4444
Often you'll interact with projects that have a specific list of dependencies (for development
4545
environments, testing environments, or the project itself). You can install the list of dependencies
4646
with pip in your venv using:
4747

48-
```
48+
```shell
4949
pip install -r <path/to/requirements.txt>
5050
```
5151

5252
Remember to re-activate your environment every time you open a new terminal, using:
5353

54-
```
54+
```shell
5555
source science/bin/activate
5656
```
5757

@@ -62,34 +62,34 @@ You can find more information on using venv for packaging
6262

6363
With conda, we can create a new environment named science (-n is the same as passing --name):
6464

65-
```
65+
```shell
6666
conda create -n science
6767
```
6868

6969
Start using your environment by activating it:
7070

71-
```
71+
```shell
7272
conda activate science
7373
```
7474

7575
You are now ready to install Scientific Python packages using `conda`!
7676
For example:
7777

78-
```
78+
```shell
7979
conda install ipython numpy scipy
8080
```
8181

8282
Some projects distribute environment files with listed dependencies with an `environment.yml` file.
8383
The first line of this file sets the environment's name. To
8484
create an environment and install the dependencies with this file, use:
8585

86-
```
86+
```shell
8787
conda env create -f <path/to/environment.yml>
8888
```
8989

9090
Remember to re-activate your environment every time you open a new terminal:
9191

92-
```
92+
```shell
9393
conda activate science
9494
```
9595

@@ -100,32 +100,32 @@ You can find more information on using conda for environments
100100

101101
With mamba, like conda, we can create a new environment named science (-n is the same as passing --name):
102102

103-
```
103+
```shell
104104
mamba create -n science
105105
```
106106

107107
Start using your environment by activating it:
108108

109-
```
109+
```shell
110110
mamba activate science
111111
```
112112

113113
You are now ready to install Scientific Python packages using `mamba`!
114114
For example:
115115

116-
```
116+
```shell
117117
mamba install ipython numpy scipy
118118
```
119119

120120
To install a specific environment from a `.yml` file, use:
121121

122-
```
122+
```shell
123123
mamba create -f </path/to/environment.yml>
124124
```
125125

126126
Remember to re-activate your environment every time you open a new terminal:
127127

128-
```
128+
```shell
129129
mamba activate science
130130
```
131131

@@ -134,34 +134,35 @@ You can find more information on using mamba in the
134134

135135
### Set up a virtual environment using uv
136136

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:
138139

139-
```
140+
```shell
140141
uv venv
141142
```
142143

143144
Start using your environment by activating it:
144145

145-
```
146+
```shell
146147
source .venv/bin/activate
147148
```
148149

149150
You are now ready to install Scientific Python packages using `uv`!
150151
For example:
151152

152-
```
153+
```shell
153154
uv pip install ipython numpy scipy
154155
```
155156

156157
To install dependencies from a requirements file, use:
157158

158-
```
159+
```shell
159160
uv pip install -f </path/to/requirements.txt>
160161
```
161162

162163
Remember to re-activate your environment time you open a new terminal:
163164

164-
```
165+
```shell
165166
source <path/to/science/>.venv/bin/activate
166167
```
167168

@@ -172,34 +173,37 @@ You can find more information on using uv for environments
172173

173174
To initialize a new project with pixi in our project called `science`, execute:
174175

175-
```
176+
```shell
176177
pixi init
177178
```
178179

179180
You are now ready to install Scientific Python packages as dependencies in this project!
180181
From the science directory, execute:
181182

182-
```
183+
```shell
183184
pixi add ipython numpy scipy
184185
```
185186

186187
To install dependencies from a file like `environment.yml`, use:
187188

188-
```
189+
```shell
189190
pixi init --import <path/to/environment.yml>
190191
```
191192

192193
Remember to re-activate your environment when you re-open a terminal. Navigate to
193194
the science folder, and execute:
194195

195-
```
196+
```shell
196197
pixi shell
197198
```
198199

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+
199203
A pixi project may have multiple environments defined in the `pixi.toml` file. To
200204
load a specific environment:
201205

202-
```
206+
```shell
203207
pixi shell --environment=<envname>
204208
```
205209

0 commit comments

Comments
 (0)