In your ebook lifetime, there may come a time that you will need to run python scripts to unlock your ebooks. There are various scripts out there on the internet, but they are all dependent on Python and Pycrypto. Getting the two programs installed can be a challenge. I’m going to give the instructions for both Windows and MAC.
1. Install 10.4 SDK (FOR MAC ONLY. If you are a PC, go to step 2).
For Mac: Under Snow Leopard, there are several python programs installed but it makes sense to run the latest which is Python 2.6. Unfortunately, if you try to install Python and Pycrytpo, you might get an error message something like this:
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
After much drama, I found a post that said that you should install the 10.4u.sdk from the Mac OS X Install DVD which came with the computer. Once the DVD loads, choose “Optional Installs”.
You’ll be presented with this screen:
From there, follow the defaults until you get to the “Custom Install on ‘Macintosh HD'” screen. Everything is checked but “MAC OS X 10.4 Support” and that is the program that you want to install.
Check the box beside it and follow the rest of the prompts.
2. Install Python
Python.org hosts the latest versions of Python. The latest stable version is Python 2.6.4. Select whichever python program that suits your Operation System. For Mac, I suggest the “Mac Installer Disk Image” and for Windows, “2.6.4 Installer“.
For Windows, make sure that you follow the suggestion of the install program and install Python at the C:\python26 location. It will be easy to find by going to “Start -> My Computer -> “Local Disk C:”. Further, this will be important for the next step.
3. Install Pycrypto
For windows, it’s fairly easy to install this program. Simply download the module from Voidspace. Make sure that you are downloading and installing the right pycrypto module. If you installed Python 2.6.4 in the prior step (step 2), then download and install “PyCrypto 2.1 for 32bit Windows and Python 2.6 (.zip)” Unpack the Zip file and you will be left with an installer program. Double click and install in the default location (meaning, just click next).
For MACs, it requires use of the Terminal program. First, download Py Crypto. The latest version is 2.1.0. Unpack the program which in Mac is generally just double clicking on the file.
Open Terminal program. Type “cd”. You are going to tell terminal program to “Change Directory” to the one that holds the pycrypto files. After you type “cd”, drag the “pycrypto-2.1.0” folder onto the terminal screen. This drops the entire path into terminal. It should now read “cd pathto/pycrypto-2.1.0” (path to being where you have the folder downloaded). Press return.
The next step is to run the install script. This is done by typing, in the terminal window, “python setup.py install” via kj in the comments:
python setup.py build (press return)
python setup.py install (press return and it ask for system password)
To double check if it is installed correctly, you go to “Macintosh HD/Library/Frameworks/Python.framework/Version/2.6/lib/python2.6” there should be a folder called “site-packages” and inside that folder should be this set of folders and files.
You are done. Python and pycrypto based scripts should now work on both Macs and PCs.