Python 2.6.1: checking for imports
I wrote a utility script for some of my Mac OSX colleagues with Python 2.6.1. Since they don't have all the required modules, I have a try-except import clause:
try:
import argparse
except ImportError:
print "argparse module missing: Please run 'sudo easy_install argparse'"
sys.exit(1)
I'm sure there are more elegant ways to handle this. Any ideas?
+3
source to share
3 answers
Your best shot is to freeze your Python code with all the required modules and distribute it as binary; it worked for me with Windows and Linux, however on Linux, make sure you have a compatible glibc version
There are some freezing tools for Mac OS X, but I haven't used them. I've only used Windows and Linux tools.
check out this link for more information
http://hackerboss.com/how-to-distribute-commercial-python-applications/
+7
source to share