How to run Python 3 on the NAS


最後修訂日期: 2024-05-08

Applicable Products

All NAS series


Scenario

Even I installed Python 3 QPKG to the App Center but I still saw version 2.7.13 while running python.


Solution

Tip

The old QTS firmware, like 4.5.4 or earlier versions might only contains Python3 3.5.2.0.2 or earlier versions.
In order to use and install newer version of Python3, please update your QTS firmware to the latest official released version.
e.g.
       Python3 3.5.2.0.2 (in QTS v4.5.4)
       Python3 3.10.4.1  (in QTS v5.0.1) 

1. Download and install Python3 in App Center (if it is not installed yet)

2. Login NAS command console via ssh using admin.

3. Add one line into python3.bash using the command below.

[~] # echo '/bin/ln -sf "${_PYTHON3_QPKG_BIN}/python3" "${_PYTHON3_QPKG_BIN}/python"' >> /etc/profile.d/python3.bash

4. source python3.bash (This action needs to be performed whenever a new ssh session is created.)

[~] # . /etc/profile.d/python3.bash

5. Update command (This action needs to be performed whenever a new ssh session is created.)

[~] # hash -r

6. After performing steps above, you are able to run python3



Further Reading

Q:  Will the above changes affect other built-in programs which needs Python2 ?

A: No. Other NAS built-in programs which needs Python2 still uses original path to run.  


這篇文章有幫助嗎?

61% 的人認為有幫助。
謝謝您,我們已經收到您的意見。

請告訴我們如何改進這篇文章:

如果您想提供其他意見,請於下方輸入。

選擇規格

      顯示更多 隱藏更多

      選擇其他偏好的語言:

      open menu
      back to top