Syntax warning when using python 3.8

Hi @WayneWWW ,
I am using Ubuntu 20.04 and my python version is 3.8.10.
While flashing i am seeing this warning prints,

Linux_for_Tegra/bootloader/tegraflash_internal.py:1978: SyntaxWarning: “is not” with a literal. Did you mean “!=”?
if sig_type is not “zerosbk”:
Linux_for_Tegra/bootloader/tegraflash_internal.py:1981: SyntaxWarning: “is” with a literal. Did you mean “==”?
if sig_type is “oem-rsa”:
Linux_for_Tegra/bootloader/tegraflash_internal.py:2416: SyntaxWarning: “is not” with a literal. Did you mean “!=”?
while count is not 0 and not check_ismb2():
Linux_for_Tegra/bootloader/tegraflash_internal.py:2425: SyntaxWarning: “is not” with a literal. Did you mean “!=”?
while count is not 0:

I think in the python scripts there has been a confusion with “is” and “==” and other literals and they are not used correctly.

Thanks
Ashik P.

1 Like

Sorry that both ubuntu20.04 and pythin3 are not yet supported.

Hej,

i came to the same issue when flashing/generating jetpack images from Debian 11 or Ubuntu 20.04.

They all come with a default python 3 instead of the deprecated python 2. You can still install python 2 on them:

sudo apt install python2

The remaining issue is that python 2 has to be called with the name python2 and Nvidia tools uses only the name python.

That is easily done with

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 20 

So if you type python python 2 gets called and Nvidia tools are happy. I regularly flash AGX Xavier boards from Ubuntu 20.04 and Debian 11 without issue with this workaround.

You can even add

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 30

then you can easily switch between the default python with

sudo update-alternatives --config python

so you can quickly switch which python version gets called when just typing python.

Most syntax issues are very small and could easily be fixed, most of them are just missing parenthesis on print statements which are now functions (cleaning it up will keep it working with python 2 as well). One file uses a package that changed name between python 2 and 3 to be PEP8 compliant. That would be an easy fix as well and could easily be done in a way compatible with both python 2 and 3. But for now, as there are many small fixes to do, i didn’t bother fixing the scripts i just switched to python 2 default when working with Nvidia tools.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.