02-05-2020 05:04 PM - edited 02-05-2020 05:05 PM
I need to use python2.7 as the default python interpreter for building an application in NI Linux RT Comms. but the default python version is set as 3.5. How do I change it? Any suggestions? Thanks in advance
02-06-2020 10:26 AM
Hi Anshumanms,
python on NI Linux Real-Time will (in general) work the same as on any other Linux system. The "python" command will be linked to a specific version of python and changing that can impact other system utilities, but other versions of python can live side-by-side and be called explicitly. It's generally a very bad idea to change the default python on a Linux OS.
For example, our systems have many utilities that depend on python 3.5 so the "python" command is linked to that. However, you can still install python2.7 and invoke it explicitly using "python2.7" or a similar command. If you want a specific script to run with a different version of python, I'd recommend looking at using shebangs. E.g., looking at putting the following line at the top of your python scripts:
#! /usr/bin/python2.7
When running a script directly (instead of calling "python <script name>"), it will use the python listed there. Note that this won't cover all use cases and does have some drawbacks that I would recommend researching.
Overall, the two things I would recommend you take away: