I have written a script in python that I would like to be able to give to some less tech-savvy friends. However, it relies on PIL and requests to function. How can I include these modules without forcing my friends to try to install them?
-
Did you try setuptools / distutils etc.?Tadeck– Tadeck2012年12月28日 10:51:20 +00:00Commented Dec 28, 2012 at 10:51
3 Answers 3
They have to install them one way or another, but there are various ways of doing so. Which one depends on how they install your script.
If they install your script with distribute, you can simply add PIL (or better Pillow) as an install dependency.
If they install your script with an installer (exe or msi) then include PIL in that installer.
If they install your script by just copying it somewhere, then your script will have to check if PIL is installed, and if not, install it, as the first thing it does before it tries to import it.
Comments
Take a look at PyInstaller - http://www.pyinstaller.org/
This allows for the creation of a simple installer which incorporates all required packages.
PIL is listed as a supported package - http://www.pyinstaller.org/wiki/SupportedPackages
Comments
It's simple. Make them to put your script in site-packages or dist-packages. They can import the script using import module and use them.