7

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.

10 Rep
  • 2,217
  • 7
  • 19
  • 33
  • Xilinx says: ' - Ubuntu Linux Workstation/Server 16.04.5, 16.04.6, 18.04.1, 18.04.2, 18.04.3, 18.04.4 (64-bit)'. See UG1144. A bit weird they haven't done the effort the reset of the word had done to move on to Python3. – vermaete Jul 19 '20 at 20:08

4 Answers4

3

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.

3

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.

Cody Piersall
  • 8,312
  • 2
  • 43
  • 57
  • This answer helped me, but I also had to `apt remove python-is-python2` otherwise apt wont install any new packages. Take this with a grain of salt though: I'm running a VM which I have no problem in discarding in case anything goes terribly wrong. Trying to install and run Petalinux 2019.1 on Ubuntu 21.10. – ricardomenzer Jan 18 '22 at 14:20
  • This seems like a good answer to install petalinux. However, I am not 100% convinced this is a final answer. Because later one (e.g. when actually using petalinux to build something), petalinux may run ".... python somePythonScript.py" and expect it to be run using python2. However, if the OS defineds python --> /usr/bin/python3 we have a problem. The script may or not execute properly and this may or not be hard to debug. – logicOnAbstractions Jan 17 '23 at 20:31
1

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
Tarek Eldeeb
  • 588
  • 2
  • 6
  • 24
  • The sed command can use a regex address instead of a line number, so the grep isn't needed: `sudo sed -i "/^Package: python2-minimal/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` – remcycles Jan 19 '22 at 23:28
0

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

10 Rep
  • 2,217
  • 7
  • 19
  • 33
fgagnaire
  • 839
  • 9
  • 18
  • This is a good guess, but not the right answer, unfortunately. The way Petalinux checks for the installed Python version is broken. It should just run `python --version`, but instead it runs `dpkg-query`, and that doesn't work on newer versions of Ubuntu. – remcycles Jan 19 '22 at 23:36