You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: setup/01_optional-python-setup-preferences/README.md
+18-20Lines changed: 18 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
4
4
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.
6
6
7
7
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.
8
8
@@ -18,9 +18,9 @@ This section guides you through the Python setup and package installation proced
18
18
19
19
20
20
> [!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.
22
22
>
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/).
24
24
>
25
25
> 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.
26
26
@@ -30,31 +30,32 @@ This section guides you through the Python setup and package installation proced
30
30
31
31
## 1. Install Python (if not installed)
32
32
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.
33
34
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:
35
36
36
37
```bash
37
38
python --version
38
39
```
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.
40
41
41
42
42
-
> [!NOTE]
43
+
> [!NOTE]
43
44
> 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.
44
45
45
46
Otherwise, if Python is not installed or is an older version, you can install it for your operating system as described below.
Download and run the installer from the official website: [https://www.python.org/downloads/](https://www.python.org/downloads/).
77
78
78
-
79
-
Obtain and execute the installer from the official website: https://www.python.org/downloads/.
80
-
81
79
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.
82
80
83
81
@@ -88,21 +86,21 @@ I recommend installing a Python version that is at least 2 versions older than t
88
86
89
87
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.
90
88
91
-
89
+
<br>
92
90
**1. Install uv**
93
91
94
92
```bash
95
93
pip install uv
96
94
```
97
95
98
-
96
+
<br>
99
97
**2. Create the virtual environment**
100
98
101
99
```bash
102
100
uv venv --python=python3.10
103
101
```
104
102
105
-
103
+
<br>
106
104
**3. Activate the virtual environment**
107
105
108
106
```bash
@@ -126,7 +124,7 @@ Optionally, you can deactivate the environment it by executing the command `deac
126
124
127
125
## 3. Install packages
128
126
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:
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.
172
170
173
-
171
+
<br>
174
172
**Start working with the code**
175
173
176
174
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
190
188
191
189
192
190
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`.
194
192
195
193
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.
Copy file name to clipboardExpand all lines: setup/01_optional-python-setup-preferences/native-uv.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
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.
4
4
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`.
6
6
7
7
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.
8
8
@@ -12,7 +12,7 @@ In this tutorial, I am using a computer running macOS, but this workflow is simi
12
12
13
13
Uv can be installed as follows, depending on your operating system.
14
14
15
-
15
+
<br>
16
16
**macOS and Linux**
17
17
18
18
```bash
@@ -25,7 +25,7 @@ or
25
25
wget -qO- https://astral.sh/uv/install.sh | sh
26
26
```
27
27
28
-
28
+
<br>
29
29
**Windows**
30
30
31
31
```bash
@@ -47,7 +47,7 @@ uv python install 3.10
47
47
```
48
48
49
49
50
-
> [!NOTE]
50
+
> [!NOTE]
51
51
> 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/).
52
52
53
53
@@ -74,7 +74,7 @@ uv add packaging
74
74
75
75
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:
76
76
77
-
77
+
<br>
78
78
**1. Create a new virtual environment**
79
79
80
80
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
83
83
uv venv --python=python3.10
84
84
```
85
85
86
-
86
+
<br>
87
87
**2. Activate virtual environment**
88
88
89
89
Next, we need to activate this new virtual environment.
@@ -100,7 +100,7 @@ On Windows (PowerShell):
100
100
.venv\Scripts\activate
101
101
```
102
102
103
-
103
+
<br>
104
104
**3. Install dependencies**
105
105
106
106
Finally, we can install dependencies from a remote location using the `uv pip` interface:
0 commit comments