python error when installing Xilinx Petalinux on Ubuntu 20.04

Viewed 3730

I got this error while I tried to install Xilinx Petalinux on Ubuntu 20.04

dpkg-query: package 'python' is not installed and no information is available Use dpkg --info (= dpkg-deb --info) to examine archive files ERROR: You have tools don't meet the version requirements: -Detected python version is less than the expected 2.7.3

I reinstalled python several times, it didn't work out.

4 Answers

I installed petalinux on Ubuntu 20.04

I had the same issue as you describe. The issue is how petalinux installer checks for version of python using dpkg and a renaming of package python to python2.7

I resolved by ensuring I installed python2 e.g. sudo apt-get install python2.7-minimal:i386 or sudo apt-get install python2.7-minimal:amd64 (I did both by mistake!) then I tricked dpkg into thinking "python" was installed by copying the section called Package: python2.7 and renaming to:- Package: python in file /var/lib/dpkg/status

This 'hack' enables dpkg to report the installed python version for installed python2.7

The petalinux installer, when querying the version of python, now succeeds and the installation progresses.

HOWEVER there is a reported issue on how the script uses sed, so the final trick is to use a sed shim as reported on xilinx forum "PetaLinux 2018.1 Install Fails on Debian Stretch"

ok. It's a bit of a hack to convince the installer to not prematurely fail. If there are more elegant solutions I'm interested to learn them.

The root cause here is that Petalinux (as of at least 2018.3) checks for the package python using dpkg-query, expecting to find python2.7, but Ubuntu 20.04 only has the packages python2 and python3. There is no package named python. The fix is pretty easy but not a thing of beauty: first install the python2 package if you don't already have it:

sudo apt install python2

Then manually add an entry for python to /var/lib/dpkg/status. Make a backup of the file before you do this. If you mess up this file you will have a bad day. This entry will work:

Package: python
Status: install ok installed
Maintainer: Fake Entry <fake@example.com>
Architecture: all
Version: 2.7.17
Description: fake package for petalinux

That's a copy of the python2 entry, with unnecessary fields removed, and an updated description. The file seems to be sorted alphabetically, so I added this entry where it should be alphabetically.


Thanks to Jon Oldroyd's answer which had basically all this information in it, but less explicit instructions. The sed fix he mentioned wasn't needed for me, in Ubuntu 20.04 and Petalinux 2018.3.

My script works in Ubuntu and Windows 10 WSL2

sudo dpkg --add-architecture i386 && sudo apt update && sudo apt-get -y install tofrodos iproute2 gawk make net-tools libncurses5-dev tftpd zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential screen pax gzip python2-minimal && \
export lin=`grep -n "Package: python2-minimal" /var/lib/dpkg/status | cut -f1 -d:` && \
sudo sed -i "${lin}i\Package: python\nStatus: install ok installed\nMaintainer: Fake Entry \nArchitecture: all\nVersion: 2.7.17\nDescription: fake package for petalinux\n" /var/lib/dpkg/status

You can then

bash petalinux-*.run ~/petalinux

I am suspecting that you need to install python2, while ubuntu 20.04 has python3 by default. (and python2 not installed as it is the end of life since Jan 2020)

You can confirm it by running:

 python2 --version

If it gives you a normal message with the version, then my answer is completely wrong.

Now if it gives you an error, then you can try to install python2 to see if it fixes it:

sudo apt install python2

info about install python2 in ubuntu

Related