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.  


这篇文章有帮助吗?

谢谢您,我们已经收到您的意见。

请告诉我们如何改进这篇文章:

如果您想提供其他意见,请于下方输入。

选择规格

      显示更多 隐藏更多
      open menu
      back to top