antony@notes:~/suse$ cat "Install-Python-3.8-on-SLE-Micro-5.5.md"
Install Python 3.8 on SLE Micro 5.5
Install Python 3.8 on SLE Micro 5.5
Login as root user
$ sudo -iOpen up a transactional-update shell session
$ transactional-update shellinstall the necessary interdependent software packages
$ zypper install zlib-devel make gccDownload the python from
www.python.org$ curl -sO https://www.python.org/ftp/python/3.8.20/Python-3.8.20.tgzUnzip it and Go to the folder
$ tar zxfv Python-3.8.20.tgz && \ cd Python-3.8.20/Make a directory where you want to put your python. I called my
.localpython3.8(name it whatever you want) and make it under the home directory. Configured the Python make$ mkdir /root/.localpython3.8 $ ./configure --prefix=/root/.localpython3.8Make and make altinstall (see difference between install and altinstall here)
$ make $ make altinstallExit the
transactional-updatesession and reboot to the new snapshot that contains the changes you have made$ exit $ rebootLogin as root user again
$ sudo -iconfigure PATH env and alias
$ cat <<'EOF' >> /root/.bashrc export PATH=/root/.localpython3.8/bin:$PATH EOF $ cat <<'EOF' >> /root/.alias alias python=/root/.localpython3.8/bin/python3.8 EOF $ exit # Login again $ sudo -i寫一個簡單的程式快速測試
$ cat <<'EOF' > test.py message = "Hello, World!" print(message) numbers = [1, 2, 3, 4, 5] for num in numbers: print(num) def add_numbers(x, y): return x + y result = add_numbers(2, 3) print(result) import datetime now = datetime.datetime.now() formatted_date_time = now.strftime("%Y-%m-%d %H:%M:%S") print(formatted_date_time) EOF執行測試程式
$ python test.py執行結果如下 :
Hello, World! 1 2 3 4 5 5 2024-11-14 16:06:00