1

I have seen many GUI applications, when launched, check the system for certain packages and plugins and if they are not there it automatically installs them. How can I do the same with my GUI right before it is launched in python? Can i do it in a .sh script or console script of some sort?

1 Answers1

1

From https://stackoverflow.com/a/4529027/1413321:

from pkg_resources import WorkingSet , DistributionNotFound
working_set = WorkingSet()

# Printing all installed modules
print tuple(working_set)

# Detecting if module is installed
try:
    dep = working_set.require('paramiko>=1.0')
except DistributionNotFound:
    pass

# Installing it (anyone knows a better way?)
from setuptools.command.easy_install import main as install
install(['django>=1.2'])
Community
  • 1
  • 1
pat34515
  • 1,959
  • 12
  • 13
  • Yes, but can i install some packages other than python modules, for example such as the Qt Qmysql package? –  Jul 23 '12 at 17:54