Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow python users with a version lower than python2.7 to run my program that uses `sysconfig`?

I made a python program which uses the sysconfig module. How can I allow python users with a python version lower than python2.7 to also run that program? I can not find this library in PyPI.

Before I had also used argparse and this was also not installed by default in python versions lower than python2.7. But I could just add it in my requirements file because it can be downloaded using pip.

like image 555
Bentley4 Avatar asked Dec 31 '25 03:12

Bentley4


1 Answers

You'll need to write a version of your code that works without sysconfig - your code would look something like this:

try:
    import sysconfig
    HAS_SYSCONFIG = True
except ImportError:
    HAS_SYSCONFIG = False

...

if HAS_SYSCONFIG:
    # sysconfig code here
else:
    # compatibility code here

You could also try backporting sysconfig to an earlier version of python and including it with your script, but that may be more work than it's worth.

like image 98
girasquid Avatar answered Jan 02 '26 17:01

girasquid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!