Skip to content

Commit 61ca01c

Browse files
committed
cosmetics
1 parent 3e3dc3c commit 61ca01c

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

setup/01_optional-python-setup-preferences/README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
There are several ways to install Python and set up your computing environment. Here, I share my personal preferences.
5+
There are several ways to install Python and set up your computing environment. Here, I share my personal preferences.
66

77
I have been a long-time user of [Conda](https://anaconda.org/anaconda/conda) and [pip](https://pypi.org/project/pip/), but recently, the [uv](https://github.com/astral-sh/uv) package has gained significant traction as it provides a faster and more efficient way to install packages and resolve dependencies.
88

@@ -18,9 +18,9 @@ This section guides you through the Python setup and package installation proced
1818

1919
 
2020
> [!NOTE]
21-
> There are alternative ways to install Python and use `uv`. For example, you can install Python directly via `uv` and use `uv add` instead of `uv pip install` for faster package management.
21+
> There are alternative ways to install Python and use `uv`. For example, you can install Python directly via `uv` and use `uv add` instead of `uv pip install` for faster package management.
2222
>
23-
> If you prefer the native `uv` commands, refer to the [./native-uv.md tutorial](./native-uv.md). I also recommend checking the official [`uv` documentation](https://docs.astral.sh/uv/).
23+
> If you prefer the native `uv` commands, refer to the [./native-uv.md tutorial](./native-uv.md). I also recommend checking the official [`uv` documentation](https://docs.astral.sh/uv/).
2424
>
2525
> While `uv add` offers speed advantages, I find `uv pip` slightly more user-friendly, making it a good starting point for beginners. However, if you're new to Python package management, the native `uv` interface is also a great way to learn.
2626
@@ -30,31 +30,32 @@ This section guides you through the Python setup and package installation proced
3030
 
3131
## 1. Install Python (if not installed)
3232

33+
If you haven't manually installed Python on your system before, I highly recommend doing so. This helps prevent potential conflicts with your operating system's built-in Python installation, which could lead to issues.
3334

34-
First, check if you have a modern version of Python installed (I recommend 3.10 or newer) by executing the following code in the terminal:
35+
However, even if you have installed Python on your system before, check if you have a modern version of Python installed (I recommend 3.10 or newer) by executing the following code in the terminal:
3536

3637
```bash
3738
python --version
3839
```
39-
If it returns 3.10 or newer, no further action is required.
40+
If it returns 3.10 or newer, no further action is required.
4041

4142
 
42-
> [!NOTE]
43+
> [!NOTE]
4344
> I recommend installing a Python version that is at least 2 versions older than the most recent release to ensure PyTorch compatibility. For example, if the most recent version is Python 3.13, I recommend installing version 3.10 or 3.11.
4445
4546
Otherwise, if Python is not installed or is an older version, you can install it for your operating system as described below.
4647

4748
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/uv-setup/python-not-found.png" width="500" height="auto" alt="No Python Found">
4849

49-
&nbsp;
50+
<br>
5051
**Linux (Ubuntu/Debian)**
5152

5253
```bash
5354
sudo apt update
5455
sudo apt install python3.10 python3.10-venv python3.10-dev
5556
```
5657

57-
&nbsp;
58+
<br>
5859
**macOS**
5960

6061
If you use Homebrew, install Python with:
@@ -70,14 +71,11 @@ I recommend installing a Python version that is at least two versions older than
7071

7172
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/uv-setup/python-version.png" width="700" height="auto" alt="Python version">
7273

73-
&nbsp;
74+
<br>
7475
**Windows**
7576

7677
Download and run the installer from the official website: [https://www.python.org/downloads/](https://www.python.org/downloads/).
7778

78-
79-
Obtain and execute the installer from the official website: https://www.python.org/downloads/.
80-
8179
I recommend installing a Python version that is at least 2 versions older than the most recent release to ensure PyTorch compatibility. For example, if the most recent version is Python 3.13, I recommend installing version 3.10 or 3.11.
8280

8381

@@ -88,21 +86,21 @@ I recommend installing a Python version that is at least 2 versions older than t
8886

8987
I highly recommend installing Python packages in a separate virtual environment to avoid modifying system-wide packages that your OS may depend on. To create a virtual environment in the current folder, follow the three steps below.
9088

91-
&nbsp;
89+
<br>
9290
**1. Install uv**
9391

9492
```bash
9593
pip install uv
9694
```
9795

98-
&nbsp;
96+
<br>
9997
**2. Create the virtual environment**
10098

10199
```bash
102100
uv venv --python=python3.10
103101
```
104102

105-
&nbsp;
103+
<br>
106104
**3. Activate the virtual environment**
107105

108106
```bash
@@ -126,7 +124,7 @@ Optionally, you can deactivate the environment it by executing the command `deac
126124
&nbsp;
127125
## 3. Install packages
128126

129-
After activating your virtual environment, you can install Python packages using `uv`. For example:
127+
After activating your virtual environment, you can install Python packages using `uv`. For example:
130128

131129
```bash
132130
uv pip install packaging
@@ -147,12 +145,12 @@ uv pip install -U -r https://raw.githubusercontent.com/rasbt/LLMs-from-scratch/r
147145

148146
<img src="https://sebastianraschka.com/images/LLMs-from-scratch-images/setup/uv-setup/uv-install.png" width="700" height="auto" alt="Uv install">
149147

150-
&nbsp;
148+
<br>
151149
**Finalizing the setup**
152150

153151
That’s it! Your environment should now be ready for running the code in the repository.
154152

155-
Optionally, you can run an environment check by executing the `python_environment_check.py` script in this repostiory:
153+
Optionally, you can run an environment check by executing the `python_environment_check.py` script in this repostiory:
156154

157155
```bash
158156
python setup/02_installing-python-libraries/python_environment_check.py
@@ -170,7 +168,7 @@ uv pip install packagename
170168

171169
If problems persist, consider [opening a discussion](https://github.com/rasbt/LLMs-from-scratch/discussions) on GitHub or working through the *Option 2: Using Conda* section below.
172170

173-
&nbsp;
171+
<br>
174172
**Start working with the code**
175173

176174
Once everything is set up, you can start working with the code files. For instance, launch [JupyterLab](https://jupyterlab.readthedocs.io/en/latest/) by running:
@@ -190,7 +188,7 @@ jupyterlab
190188

191189

192190

193-
This section guides you through the Python setup and package installation procedure using `uv`.
191+
This section guides you through the Python setup and package installation procedure using `uv`.
194192

195193
In this tutorial, I am using a computer running macOS, but this workflow is similar for Linux machines and may work for other operating systems as well.
196194

setup/01_optional-python-setup-preferences/native-uv.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This tutorial is an alternative to *Option 1: Using uv* in the [README.md](./README.md) document for those who prefer `uv`'s native commands over the `uv pip` interface. While `uv pip` is faster than pure `pip`, `uv`'s native interface is even faster than `uv pip` as it has less overhead and doesn't have to handle legacy support for PyPy package dependency management.
44

5-
Otherwise, similar to *Option 1: Using uv* in the [README.md](./README.md) , this section guides you through the Python setup and package installation procedure using `uv`.
5+
Otherwise, similar to *Option 1: Using uv* in the [README.md](./README.md) , this section guides you through the Python setup and package installation procedure using `uv`.
66

77
In this tutorial, I am using a computer running macOS, but this workflow is similar for Linux machines and may work for other operating systems as well.
88

@@ -12,7 +12,7 @@ In this tutorial, I am using a computer running macOS, but this workflow is simi
1212

1313
Uv can be installed as follows, depending on your operating system.
1414

15-
&nbsp;
15+
<br>
1616
**macOS and Linux**
1717

1818
```bash
@@ -25,7 +25,7 @@ or
2525
wget -qO- https://astral.sh/uv/install.sh | sh
2626
```
2727

28-
&nbsp;
28+
<br>
2929
**Windows**
3030

3131
```bash
@@ -47,7 +47,7 @@ uv python install 3.10
4747
```
4848

4949
&nbsp;
50-
> [!NOTE]
50+
> [!NOTE]
5151
> I recommend installing a Python version that is at least 2 versions older than the most recent release to ensure PyTorch compatibility. For example, if the most recent version is Python 3.13, I recommend installing version 3.10 or 3.11. You can find out the most recent Python version by visiting [python.org](https://www.python.org/downloads/).
5252
5353
&nbsp;
@@ -74,7 +74,7 @@ uv add packaging
7474

7575
Alternatively, you can still install the dependencies directly from the repository using `uv pip install`. Note that this requires creating and activating the virtual environment manually:
7676

77-
&nbsp;
77+
<br>
7878
**1. Create a new virtual environment**
7979

8080
Run the following command to manually create a new virtual environment, which will be saved via a new `.venv` subfolder:
@@ -83,7 +83,7 @@ Run the following command to manually create a new virtual environment, which wi
8383
uv venv --python=python3.10
8484
```
8585

86-
&nbsp;
86+
<br>
8787
**2. Activate virtual environment**
8888

8989
Next, we need to activate this new virtual environment.
@@ -100,7 +100,7 @@ On Windows (PowerShell):
100100
.venv\Scripts\activate
101101
```
102102

103-
&nbsp;
103+
<br>
104104
**3. Install dependencies**
105105

106106
Finally, we can install dependencies from a remote location using the `uv pip` interface:
@@ -114,12 +114,12 @@ uv pip install -U -r https://raw.githubusercontent.com/rasbt/LLMs-from-scratch/r
114114
&nbsp;
115115
## 4. Run Python code
116116

117-
&nbsp;
117+
<br>
118118
**Finalizing the setup**
119119

120120
Your environment should now be ready to run the code in the repository.
121121

122-
Optionally, you can run an environment check by executing the `python_environment_check.py` script in this repository:
122+
Optionally, you can run an environment check by executing the `python_environment_check.py` script in this repository:
123123

124124
```bash
125125
uv run python setup/02_installing-python-libraries/python_environment_check.py
@@ -131,7 +131,7 @@ uv run python setup/02_installing-python-libraries/python_environment_check.py
131131

132132

133133

134-
Or, if you don't want to type `uv run python` ever time you execute code, manually activate the virtual environment first.
134+
Or, if you don't want to type `uv run python` ever time you execute code, manually activate the virtual environment first.
135135

136136
On macOS/Linux:
137137

@@ -152,7 +152,7 @@ Then, run:
152152
python setup/02_installing-python-libraries/python_environment_check.py
153153
```
154154

155-
&nbsp;
155+
<br>
156156
**Launching JupyterLab**
157157

158158
You can launch a JupyterLab instance via:

0 commit comments

Comments
 (0)