Repository navigation
Expand file tree
/
Copy pathinstall_python3.12
More file actions
143 lines (113 loc) · 4.43 KB
/
Copy pathinstall_python3.12
File metadata and controls
143 lines (113 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
To install Python 3.12.4 on your Debian PRoot environment, you can follow these steps. We'll download the source code, build it, and install it. Here's a detailed guide:
### Step-by-Step Instructions
1. **Update Package List and Install Dependencies**:
First, update your package list and install the necessary dependencies for building Python from source.
```sh
sudo apt update
sudo apt install -y \
build-essential \
libssl-dev \
zlib1g-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libgdbm-dev \
libdb5.3-dev \
libbz2-dev \
libexpat1-dev \
liblzma-dev \
tk-dev \
libffi-dev \
wget
```
2. **Download Python 3.12.4 Source Code**:
Download the source code for Python 3.12.4 from the official Python website.
```sh
wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz
```
3. **Extract the Tarball**:
Extract the downloaded tarball.
```sh
tar -xf Python-3.12.4.tgz
cd Python-3.12.4
```
4. **Configure the Build**:
Configure the Python source for your system.
```sh
./configure --enable-optimizations
```
5. **Build and Install Python**:
Build and install Python. This step might take a while.
```sh
make -j$(nproc)
sudo make altinstall
```
The `altinstall` option is used to prevent overwriting the default `python3` binary.
6. **Verify the Installation**:
After the installation is complete, verify that Python 3.12.4 is installed correctly.
```sh
python3.12 --version
```
### Detailed Explanation
- **Updating Package List**: Ensures your package lists are up to date.
- **Installing Dependencies**: Installs the necessary packages for building Python from source, including compilers and libraries.
- **Downloading Source Code**: Fetches the source code for Python 3.12.4.
- **Extracting Tarball**: Unpacks the downloaded tarball so you can access the source files.
- **Configuring Build**: Prepares the build environment tailored to your system.
- **Building and Installing**: Compiles the source code and installs Python 3.12.4 without interfering with your system’s default Python.
- **Verifying Installation**: Checks that the newly installed Python version is working correctly.
By following these steps, you should have Python 3.12.4 installed and running in your Debian PRoot environment.
To make Python 3.12.4 the default Python interpreter and understand where it is installed, follow these steps:
### Step 1: Verify Installation Location
When you use the `make altinstall` command, Python is typically installed in `/usr/local/bin`. Verify the installation with:
```sh
ls /usr/local/bin/python3.12*
```
### Step 2: Update Alternatives (Preferred Method)
Using the `update-alternatives` system allows you to manage multiple versions of the same program on your system.
1. **Add Python 3.12 to Alternatives**:
```sh
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 1
```
2. **Set Python 3.12 as Default**:
```sh
sudo update-alternatives --config python3
```
You'll see a list of installed Python versions. Select the one corresponding to Python 3.12.
### Step 3: Update Symlinks Manually (Alternative Method)
If you prefer or if `update-alternatives` is not available, you can manually update the symlink for `python3`.
1. **Remove Existing Symlink**:
```sh
sudo rm /usr/bin/python3
```
2. **Create New Symlink**:
```sh
sudo ln -s /usr/local/bin/python3.12 /usr/bin/python3
```
### Step 4: Verify the Default Python Version
After updating the symlink or using `update-alternatives`, verify that Python 3.12.4 is now the default Python version:
```sh
python3 --version
```
### Summary of Installation Location
The Python binary is typically installed in `/usr/local/bin` when built from source. You can confirm the exact location with:
```sh
which python3.12
```
### Full Example Workflow
Here is a complete example of the commands you might use:
1. **Verify Installation Location**:
```sh
ls /usr/local/bin/python3.12*
```
2. **Add and Configure Alternatives**:
```sh
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 1
sudo update-alternatives --config python3
```
3. **Verify**:
```sh
python3 --version
```
By following these steps, Python 3.12.4 should become your default Python interpreter, and you will know where it is installed on your system.