0

I've a python script to be executed on N systems, but some of them might be Python 2.4 and do not include json module.

I've found simplejson module compatible with Python 2.4 in tar.gz form, is it possible to ship the module together with the script and having it installed on the fly?

For example:

try:
   import json
except:
   sys.out('old version found, going to install simplejson')
   installing simplejson.....?
   import simplejson as json

Part II: how to install the package w/o PIP?

Simply_me
  • 2,340
  • 2
  • 14
  • 24

1 Answers1

0

The easiest thing would be to only import simplejson, and then make sure you use the Py2.4-compatible version in all your environments (I'm assuming the python version can't be upgraded).

If you still want to install simplejson on the fly, I would look at the following SO thread:

Installing python module within code

Hopefully you can setup those systems to have pip (since you would be adding this script and running it in these systems, I'm assuming you have write and execute permissions).

pachewise
  • 214
  • 1
  • 5