python-configparser not found on ubuntu 22.04

496 views Asked by At

I'm trying to install this https://github.com/pimoroni/displayhatmini-python on a raspberry pi running Ubuntu 22.04 and when I run the install.sh it fails on this:

E: Unable to locate package python-configparser

Unfortunately, I'm not that familiar with python. I'm trying to install it using this:

apt install python-configparser

but I get this:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python-configparser

python3 -V gives me Python 3.10.12

So I also tried apt-get install -y python3-configparser but that also comes up as not found.

Would I need to uninstall python3 and install python instead? Not sure how to resolve.

Thanks.

Update:

Thanks to the comment below, I have installed this but the error persists:

E: Unable to locate package python-configparser
./install.sh: line 145: python: command not found
Error parsing configuration...

This is the code it refers to:

apt_pkg_install python-configparser

CONFIG_VARS=`python - <<EOF
from configparser import ConfigParser
c = ConfigParser()
c.read('library/setup.cfg')
p = dict(c['pimoroni'])
# Convert multi-line config entries into bash arrays
for k in p.keys():
    fmt = '"{}"'
    if '\n' in p[k]:
        p[k] = "'\n\t'".join(p[k].split('\n')[1:])
        fmt = "('{}')"
    p[k] = fmt.format(p[k])
print("""
LIBRARY_NAME="{name}"
LIBRARY_VERSION="{version}"
""".format(**c['metadata']))
print("""
PY3_DEPS={py3deps}
PY2_DEPS={py2deps}
SETUP_CMDS={commands}
CONFIG_TXT={configtxt}
""".format(**p))
EOF`
1

There are 1 answers

0
Stephen C On

If you are using Python 3, the configparser module is part of the standard libraries (see https://docs.python.org/3/library/configparser.html), so it does not need to be a dependency.

The Ubuntu python-configparser package is actually a backport of the Python 3 configparser module for Python 2.7. Since Python 2.7 is deprecated in Ubuntu 22.04, they have (apparently) dropped that package.

But looking at the project you are actually trying to install, it looks like you can modify the install.sh script to comment out the apt_pkg_install python-configparser ... and the section of the script that installs for Python 2.

I see that someone (you?) has just created an issue tracker for this: https://github.com/pimoroni/displayhatmini-python/issues/17