Skip to content

Commit e6dc8c9

Browse files
committed
add in pixi and uv commands
1 parent 0131871 commit e6dc8c9

File tree

1 file changed

+89
-11
lines changed

1 file changed

+89
-11
lines changed

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

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ environments, testing environments, or the project itself). You can install the
4343
with pip in your venv using:
4444

4545
```
46-
pip install -r requirements.txt
46+
pip install -r <path/to/requirements.txt>
4747
```
4848

4949
Remember to re-activate your environment every time you open a new terminal, using:
@@ -52,7 +52,7 @@ Remember to re-activate your environment every time you open a new terminal, usi
5252
source science/bin/activate
5353
```
5454

55-
### Set up a virtual environment using conda
55+
### Set up an environment using conda
5656

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

@@ -73,12 +73,12 @@ For example:
7373
conda install ipython numpy scipy
7474
```
7575

76-
Often you'll interact with projects that have a specific list of dependencies (for development
77-
environments, testing environments, or the project itself). You can install the list of dependencies
78-
with conda in your environment using:
76+
Some projects distribute environment files with listed dependencies with an `environment.yml` file.
77+
The first line of this file sets the environment's name. To
78+
create an environment and install the dependencies with this file, use:
7979

8080
```
81-
conda install --file requirements.txt
81+
conda env create -f <path/to/environment.yml>
8282
```
8383

8484
Remember to re-activate your environment every time you open a new terminal:
@@ -87,7 +87,7 @@ Remember to re-activate your environment every time you open a new terminal:
8787
conda activate science
8888
```
8989

90-
### Set up a virtual environment using mamba
90+
### Set up an environment using mamba
9191

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

@@ -108,16 +108,94 @@ For example:
108108
mamba install ipython numpy scipy
109109
```
110110

111-
Often you'll interact with projects that have a specific list of dependencies (for development
112-
environments, testing environments, or the project itself). You can install the list of dependencies
113-
with mamba in your environment using:
111+
To install a specific environment from a `.yml` file, use:
114112

115113
```
116-
mamba install --file requirements.txt
114+
mamba create -f </path/to/environment.yml>
117115
```
118116

119117
Remember to re-activate your environment every time you open a new terminal:
120118

121119
```
122120
mamba activate science
123121
```
122+
123+
### Set up a virtual environment using uv
124+
125+
To create a new environment using uv in our project folder called `science`:
126+
127+
```
128+
uv venv
129+
```
130+
131+
Start using your environment by activating it:
132+
133+
```
134+
source .venv/bin/activate
135+
```
136+
137+
You are now ready to install Scientific Python packages using `uv`!
138+
For example:
139+
140+
```
141+
uv pip install ipython numpy scipy
142+
```
143+
144+
To install dependencies from a requirements file, use:
145+
146+
```
147+
uv pip install -f </path/to/requirements.txt>
148+
```
149+
150+
Remember to re-activate your environment time you open a new terminal:
151+
152+
```
153+
source <path/to/science/>.venv/bin/activate
154+
```
155+
156+
You can find more information on using uv for environments
157+
[here](https://docs.astral.sh/uv/pip/environments/#creating-a-virtual-environment).
158+
159+
### Set up a virtual environment using pixi
160+
161+
To initialize a new project with pixi in our project called `science`, execute:
162+
163+
```
164+
pixi init
165+
```
166+
167+
You are now ready to install Scientific Python packages as dependencies in this project!
168+
From the science directory, execute:
169+
170+
```
171+
pixi add ipython numpy scipy
172+
```
173+
174+
To install dependencies from a file like `environment.yml`, use:
175+
176+
```
177+
pixi init --import <path/to/environment.yml>
178+
```
179+
180+
Remember to re-activate your environment when you re-open a terminal. Navigate to
181+
the science folder, and execute:
182+
183+
```
184+
pixi shell
185+
```
186+
187+
A pixi project may have multiple environments defined in the `pixi.toml` file. To
188+
load a specific environment:
189+
190+
```
191+
pixi shell --environment=<envname>
192+
```
193+
194+
You can find more information on using pixi
195+
[here](https://docs.astral.sh/uv/pip/environments/#creating-a-virtual-environment).
196+
197+
198+
199+
200+
201+

0 commit comments

Comments
 (0)