How to Install Python and Pycrypto on Snow Leopard and PC
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:
Choose “Xcode.mpkg”
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)
then
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.
A thousand thanks for this. I’d been concerned about installing Python on a Mac.
I have been reading ebooks for 7 years, but I’ve never needed to break any codes for anything. What does this software do (and pardon the ignorance).
@MIreya: Either you only read non-DRM books or you only use one DRM’d ebook reader. If you switch devices or read on more than one type, then your DRM’d books can’t be moved between them. For example, I’ve read on Palm platforms since the Palm Pilot (and before DRM), so I always bought everything in pdb or later mobi. When I got my Sony Reader I couldn’t read those books on it. When I switched to a Nokia phone I could read the mobi books (there is a reader for my version of Symbian) but I couldn’t read the pdb books because the eReader software doesn’t work on it. So I could either not read the books, buy another version, or strip the DRM and convert the pdb files to prc (mobi).
The DRM decryption files all run via python, and some need pycrypto as well.
Hope that helps.
ETA: Non-DRM’d books can be converted to different file formats (via Calibre, for example) and read by different ebook formats. But DRM’d books can’t. Hence the need to decrypt.
@Sunita: Thanks for the explanation. 90% of what I have is non-DRM as I got it from small epubs like EC, Loose Id, Samhain, etc. I use as e-readers either my Dell Pocket PC, which is ancient by modern standards as I got it in 2003, but I can read Mobi, Adobe, HTML, Microsoft reader, DOC, TXT and probably at least two other formats, without having to worry about anything. My other e-reader is a Sony e-reader. I use it for books purchased directly from their store, though I can now use it with a couple other formats.
I’ll download and install it. The way things are going in the industry it will be a matter of when I’ll need to use this software, not a matter of if *sigh*
Thanks, Jane. I’ve been using my PC virtual machine for Python scripts so this is great.
Just in case others were having the same problem as me:
when I typed in the last command for pycrypto:
python install setup.py
it didn’t work for me. It kept on saying unable to install. So instead of that command I typed in
python setup.py build (press return)
then
python setup.py install (press return and it ask for system password)
This is the only way I was able to get Pycrypto to work with Python.
Thanks again Jane!
Thank you, Jane. I’d been meaning to do this, but just didn’t know which to grab. Finally using python will expand my shopping options a bit.
Thanks for this clear info, although I found out how to fiddle with it via this post a year ago. Yours is much clearer and the post has no info for Macs. In Germany wouldn’t be able to legally post even this much info.
@Mireya: Honestly I’ve found it wise to decrypt all my legally bought drm-books right away. And back them up away from the eReaders or the PC – you never know when those will fail.
Adobe just now announced with the new edition of their Digital Editions software that Adobe Content Server 3 has been shut down. All the people who hadn’t transferred the drm-books from being authorised there to Adobe Content Server 4 will no longer be able to transfer their legally bought books to any other device.
And then there’s the iPAD which is planning not to use Adobe DRM at all, but their own version – and the fact that Barnes & Noble .epub books (for the Nook) with Adobe DRM can’t be read on the Sony eReader…
The more I read the clearer it becomes that getting rid of the drm as soon as possible is the safest way to be sure not to have to buy the books again with any new reading platform.
@Estara: thanks for the advice. I am going to be doing that soon. I already keep a backup of all my ebooks in a flash drive because I have been forced to reformat my PCs HD a couple of times over the past 4 years.
@Mireya: I’m over-protective of my books, but better safe than sorry I say ^^. I hope my comment will be rescued from the spam folder in some form.
Thanks so much for the detailed instructions, Jane. I have been searching for python script instructions for the non-computer experts over the past month.
@Jane We run Windows Vista 64 bit. What versions should I use?
Um.. dumb question here, but from what formats does Python change to what formats?
LVLM, Python doesn’t change anything to anything. It’s the language that most/all DRM uninfection scripts are written in. Once you have Python up and working you still need the scripts like Inept (ePub and PDF versions), mobidedrm (Mobi/Prc) and ereader2html (eReader PDB) and the various scripts for other formats like Kindle 4 PC, Topaz and B&N ePub.
@Brian: Would someone be able to post links to these programs?
I have hundreds of books with DRM, and I know I need to be proactive not to lose the ability to read them.
You can find them via a Google search. I don’t think they’d want them posted here as it might be (probably is) a DMCA violation.
Inept has versions for ePub and PDF
mobidedrm is for Mobipocket, etc.
There’s also ConvertLit for MS Reader (LIT) files. That one doesn’t require Python or anything like that.
I know many folks who remove DRM as soon as they buy a book. Not for any nefarious purposes, but just as a way to make sure what they bought will be usable on future devices.
I am looking into the scripts part. I see already that this is going to take me a bit to figure out. This is not software that simply involves clicking on a few buttons. You need scripts, then you need to change the extension of those scripts once you have them saved on your system, then you have to go to command prompt … where’s the Advil …
Thanks Brian- you’re very helpful. All this stuff seems maybe too complicated for my tech ability level. Just understanding how it works though is a step in the right direction. I’m so sick of not being able to buy some books because my reader can’t read them.
Sits with Mireya.
What happens if you’ve already lost your rights to open your eBook? For example, I bought a bunch of MS Reader LIT eBooks a few years ago and I can no longer open them on my current laptop, since I no longer remember the password for the account I activated them under. (And my old laptop bit the dust.) Is there a script to remove the DRM on a file you can no longer open, or does it have to be a reader file that you can still access? Because convertlit won’t work if you don’t have access to the eBook.
I tried opening a support call to retrieve my password from Microsoft so I could just re-activate the books under my old account, but they were absolutely no help whatsoever.
As a Mac OS user, this plus a post on the Viva eBooks blog has broken through the barrier that stopped me from switching from print to digital book buying in the past. Thanks!
@Suzanne Allain I’m not sure. I think if you can’t open your books, you wouldn’t be able to use these programs to open them up.
@Jane: Thanks, Jane. I think you’re right. I’m starting to understand the frustration with DRM.
@Suzanne Allain: I am still messing around figuring scripts, but I can tell you that if you can’t open them now, you’ll not be able to remove the DRM. I have the same situation with a few Mobipocket ones.
It’s frustrating to learn this, but honestly, in the end, it is going to be worth the effort.
*grabs the bottle of Advil and walks away*
Jane, thank you so much for including these instructions. I needed them quite badly, and couldn’t believe that you’d posted these instructions exactly when I needed them. My Nook and I thank you!
@Nicole: I’m so glad it worked out for you.
Jane –
You are a Goddess for posting this. I’m new to the whole Ebook thing and just bought a Kindle DX in November. It’s been a learning experience I can tell you. I also have a new Mac Mini (December) Running Snow Leopard 10.6.2. My problem, I think, is with installing PYCrypto 2.1.0.
When I run the install script, it never asks for a password and instead gives me this error message:
[localhost:~/Downloads/pycrypto-2.1.0] rbarnes% python setup.py install
running install
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
running install_lib
running install_egg_info
Removing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pycrypto-2.1.0-py2.6.egg-info
Writing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pycrypto-2.1.0-py2.6.egg-info
[localhost:~/Downloads/pycrypto-2.1.0] rbarnes%
I’m asking because you mentioned much drama learning about the xcode for 10.4 install. Could it be that the GMP library mentioned in this error message is a part of that? I thought I installed it right, but maybe not. Also I noticed that the python 2.6.4 dmg file is labeled for macosx 10.3. Do I maybe need one for a newer version of macosx?
The test you describe:
“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— Nope… not there.
Do you have any other tests to suggest to see if the earlier steps in your spell… er procedure worked properly? And do you have any idea at all what this “GMP library” is and where I might get one for my very own?
It reminds me a bit of playing Greyhawk way back in the day… “I’ve studied the Arcane Codexes, and consulted with a wizard (that would be you), but darn it…. I think I’ve mispronounced one syllable of the incantation and I’m not sure which one. ;-)
Best,
yukinoho
@yukinojo: Yes, I think if you are having the “egg info” problem it is due to not having the right sdk installed. Did you install 104u (I have a description of how to find it in the above post)?
If so, go ahead and install all the rest of the xcode package.
You’ll need to delete the python install if you added version 2.6 and then reinstall it after you have added the xcode package.
I’m the new owner of a Sony Touch and I was wondering if, using python and calibre, I would, say, be able to ‘break open’ Secure eReader format ebooks, then convert them to a file format my Sony can read?
@Christine M.: You can but you would need the secure ereader script.
Damn. So much for the attractiveness of fictionwise’s micropay dollars/rebates.
@Christine M.: Once you have the two programs installed, though, the scripts are easy to use. Just double click and follow the instructions.
Great helps on getting the Python scripts to work on my 10.5.6 Mac. The Xcode packages for the 10.5.6 OS x are known as the SDK 10.3.6 Xcode files and are in the Optional installations section of the startup disk.
I have dine the build and installs of Python and PyCrypt seemingly satisfactorily. I have downloaded the latest versions of ineptkeymac.py and ineptepb.pyw. Running ineptkeypac.py “appears” to generate a ADEPTKEY.DER. When I feed that key into the Python GUI when running ineptepub.pyw. Once the “Decrypt” button is clicked, an error pops up withing the applet saying “Error: List assignment index out of range” Any idea where I should look for the bug causing this and how to fix it? No DRM-free output document is created at all.
Oops… small typo above… “ineptkeypac.py” SHOULD BE “ineptkeymac.py” Sorry for any confusion.
@MEC I don’t know the answer to your question. Are you sure you have Pycrypto installed? I would check for that.
@MEC:
You are right… something went wobbly in the original Pycrypto install.
I removed Python then reinstalled Xcode, reinstalled Python 2.6, and then attempted to run the setup.py build process. I ended up with a “GMP not found” error…..
blahblah-macbook-pro:pycrypto-2.1.0 blahblah$ python setup.py build
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
blahblah-macbook-pro:pycrypto-2.1.0 blahblah$
Any ideas on the GMP error?
@mec:
looks like the egg file is where it is supposed to be
/Library/Frameworks/Python.framework/Version/2.6/lib/python2.6/site-packages
the Crypto folder and pycrypto-2.1.0-py2.6.egg-info plus a readme file are all in the site-packages folder
Hi Jane: This is my first time attempting to do anything with Python. I know little about Terminal, but I’m getting a similar error when I try to install PyCryto. Here’s what I get:
Jamies-iMac-2:~ apple$ cd /Users/apple/Downloads/pycrypto-2.1.0
Jamies-iMac-2:pycrypto-2.1.0 apple$ python setup.py build
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building ‘Crypto.Hash.MD2’ extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe -O3 -fomit-frame-pointer -Isrc/ -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/MD2.c -o build/temp.macosx-10.5-i386-2.5/src/MD2.o
unable to execute gcc: No such file or directory
error: command ‘gcc’ failed with exit status 1
Jamies-iMac-2:pycrypto-2.1.0 apple$ python setup.py install
running install
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building ‘Crypto.Hash.MD2’ extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe -O3 -fomit-frame-pointer -Isrc/ -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c src/MD2.c -o build/temp.macosx-10.5-i386-2.5/src/MD2.o
unable to execute gcc: No such file or directory
error: command ‘gcc’ failed with exit status 1
I could really use some help. Thanks
@Wren: What version are you installing? I googled your error and came up with this:
https://bugs.launchpad.net/pycrypto/+bug/472338
@mec: Maybe try re downloading the pycrypto file? It may be the file you dl’d was corrupted? Are you downloading and installing the most recent version of pycrypto? (2.1 instead of 2.0.1)
@Jane: I’m sorry to sound so ignorant, but what exactly does this Python do? And why would I need to be using it?
I have a collection of ebooks and would like to know if I should be using this script/program for some reason or another.
Thank you.
@Jane:
Thanks for your quick reply, Jane.
> @yukinojo: Yes, I think if you are having the “egg info†problem it is
> due to not having the right sdk installed. Did you install 104u (I have a
> description of how to find it in the above post)?
Jane, I haven’t been able to find the “above post” you reference here I did the xcode install you described in your original post. Is that the 104u thingy you mention?
I think I’ll go back to your original post and see if I can find something about the egg info problem you mention.
>
> If so, go ahead and install all the rest of the xcode package.
I’ll see if I can find more of the Xcode package sosome where and install it.
> You'll need to delete the python install if you added version 2.6 and then
> reinstall it after you have added the xcode package
I’ll see if there’s an uninstall in the python s.6 package, and try to do this.
Thanks for the tips, and sorry if I’m such a nube that most of this doesn’t mean anything to me, “egg info” and “104u” might as well be Turkish to me, but I’ll see what I can find out.
@Jane:
Jane,
Sorry more problems.
> You’ll need to delete the python install if you added version 2.6
>
> and then reinstall it after you have added the xcode package.
>
I can’t figure out how to delete the Python install. I could put the Python 2.6 folder in the Applications folder into the trash, but that would still leave all the thousands and thousands of files and folders that were put in other places. I don’t know where they are or how to get rid of them.
@Jane:
Jane,
I want to apologize for all those posts in reply to your reply. This is all very confusing and frustrating to me. I REALLY understand what you ment when you mentioned “much drama.” While googling and trying to find out what things ment, I found a post on another board that said Apple decided to leave out an important part of Xcode in Snow Leopard because it was changing too fast. So Python is apparently broken in Snow Leopard because of Apple! Maybe they should fix it.
Best,
Yukinojo
@Liv: Liv, I didn’t know either, but it was kindly explained to me at the beginning of the thread. This software helps to remove DRM from ebooks. Further down in the thread mention of scripts was made, so that gave me further information. From figuring out what the scripts were I I had to use Google. It has been quite enlightening and suffice it to say, I can now read my ebooks in any device I want without any restriction. It can be a very frustrating process to learn, but if you buy a lot of DRMd ebooks, you certainly would benefit from learning more about this.
If you do decide to go for this, you will also need Calibre, which Jane has extensively posted about.
I love learning new stuff :D
@Mireya: Mireya, thanks so much for getting back to me. I have no idea if mine are DRM’d or not. I use the same books on my nook and my pc and they haven’t blown up or anything.
This is just copyright stuff right? This doesn’t turn a epub or pdb into a pdf or html or anything does it?
I get irritated that I can’t buy from the Sony/Border’s store for my nook, or ebookwise, Amazon, etc..
Thanks again.
@yukinojo: If you are unsure then you probably don’t want to do it. I uninstalled Python by dragging it to the trash can.
It does work on my Snow Leopard installation.
@Liv: Calibre is the program that converts from one format to another. The scripts remove the DRM so that you can buy at other stores.
@Liv: If you are buying your ebooks from places like Barnes and Noble (nook), Amazon (Kindle), ebookwise, Fictionwise, Sony Reader, etc. your books most definitely are DRMd. If you buy mostly from small epubs like Samhain Publishing, Loose Id, etc. they are not.
This is why these programs Jane has been talking about and explaining become really useful tools. It takes a bit to figure it all out, but in the end, I think it’s worth the hassle.
@Mireya: Mireya, Thanks again. I’ll give it a go. I don’t want my ebooks to become useless. I’m think my Nook will become obsolete before my ebooks will.
Let’s hope publishers don’t start doing self destructs on paperbacks.
Off to wrangle a Python…
Jane.. thanks very much. I have redownloaded the Pycrypto file 2.1 (NOT 2.0.1) and keep running smack into the same GMP errors when attempting to the build process. Despite the GMP error and appearance that the build script is exiting, there is an egg file where you say it should be. Seems awfully odd that it is there, despite to build and install script not running properly.
I appreciate any insights.. Thanks.
@MEC Have you tried to run any of the scripts? The error might be meaningless. Try to run a script and see what happens.
@Jane:
First, I’m on Leopard (10.5.8), not Snow Leopard, so I don’t know if that’s a problem… I’ve tried with Python 2.5 and Python 2.6 both using PyCrypto 2.1.0. No luck. No egg file, still the same “missing GMP” warning and the same “gcc: No such file or directory” error. Anyone have any advice? I’m about ready to give it up.
@yukinojo I’m not very conversant in this either. The xcode installation I refer to is the 10.4u thing
I’m uncertain of the egg problem. You may have to google for that.
Deleting the Python install is done by dragging the python 2.6 folder to the trash.
@MEC Unfortunately I don’t have any answers. I recommend trying the Mobile read forums. It is populated with a number of really smart individuals.
@Jane: @Jane:
I’ve been using Google to try to find out more about the problem I’m having with using your Python install procedure on my Mac. I think I’m getting better at picking search criteria, which is, after all, the key to using a search engine. I found this site:
http://ioanna.me/2009/09/installing-pyobjc-xcode-templates-in-snow-leopard/
Caution–It’s written in HIgh Nerdish, and may be difficult for an ordinary mortal to follow. I know I only understand a part of it. The key point the writer makes is this:
“If you've tried to create a cocoa-python XCode project in Snow Leopard, you've probably realised that the templates for creating Python projects in XCode have not been included. The reason given for removing the Python (and Ruby) project templates from XCode was that the templates were changing faster than XCode updated.”
Of course, I’m not trying to”…create a cocoa-python XCode project in Snow Leopard,” and probably never will. I think what this is saying is that the Most Nerdly Wizards at Apple broke Python, and we mere mortal users will have to live with it until they relent and decide to unbreak it.
Certainly the procedure outlined in this is scary as hell, and I don’t think I’ll ever try it. *Sigh* I just wish it wasn’t necessary to even know this stuff. What a dreamer I am, eh?
I knew about dragging the app package to the trash. I’m just concerned about all the files and folders left behind.
I’m thinking the ultimate reason for the missing GMP problem that many of us seem also to be having is that we are using new Snow Leopard/Intel Macs, or Systems with a “clean install” of Snow Leopard, which would mean that there are no old files on the system from earlier versions of MacOsX. This may be why the GMP library isn’t there.
What to do about it, beyond waiting patiently and practising calm, I don’t know. Any ideas?
Best,
yukinojo
@ Jane
I’ve got Windows 64 bit installed – the instructions above are for 32 bit – do you know which versions I should use for 64 bit?
thx!
@Kaetrin: You would choose to install the windows 64 bit versions, I presume, but in the same manner.
@Jane
I worked out which one to use for Python but I couldn’t tell which one to use for the Pycrypto.
@Kaetrin I’m not sure. Maybe install the original source code and do a manual build?
Jane,
An interesting new development. I ran Software Update this morning, and discovered that Apple has released an Update for Xcode that brings it up to Xcode version 3.2.1. I installed it, and was able to successfully install pycrypto! Well, sort of. When I do the test you describe in your procedure, ie. checking the folder at Macintosh HD/Library/Frameworks/Python.framework/Version/2.6/lib/python2.6 for a folder called “site-packages†it’s there and it has the files you list in it. And we all rejoiced! “Yaaaay!!”
Sadly, I still get the “warning: GMP library not found; Not building Crypto.PublicKey._fastmath.” ;-( Aaand the mobidedrm script still fails with a Python: No match error. Apparently Crypto.PublicKey._fastmath is important. Still, this is an improvement, and folks should consider running Software Update because it seems to fix the egg-info problem. As for the rest I shall vow to endeavor to persevere because I am so very civilized (sorry, obscure movie reference).
Best,
yukinojo
I have been using python 2.6, pycrypto 2.l, indeptepub.decrypter v.2 on XP with no problem until today. All of a sudden I am told when I go to put the output file name in that there is no file or path. I uninstalled and reinstalled everything and still get the same message. I want to decrypt e.pubs from Adobe Digital Editions. Any help you can give me?
If you have a Mac, this link may be “just what the doctor ordered.”
http://pastebin.com/SL3xH9a8
@Jane: @Christine M.: Once you have the two programs installed, though, the scripts are easy to use. Just double click and follow the instructions.
I’ve double clicked a lot of things and nothing is running on my pc. Is there a website that might have some detailed info for me on it? I’ve tried googling it, but that’s not much help.
@mec:
Fixed the GMP library error – first of all even if you have admin access if your mac has multiple users you have to do this under the main account. (warning, I am computer functional, not computer literate and my in-house help desk was required My in house help desk says this may not be true on every mac, but might have been because I didn’t have software developer tools on mine)
First we updated / installed the GMP library from MacPorts
http://www.macports.org
Then we installed Pcrypto and it built.
When I returned to my user account I could use some scripts, but I had a problem with one not recognizing pcrypto that was solved by opening it with python2.6 directly.
@meoskop:
Can you please give me a step-by-step on how one finds the file on macreports.org and then how do you install it? I’m really stuck here, thanks!
Thanks so much for the guide. I am always sad when I easy install something on my mac which needs to build something. But with your post I was able to get it work easily!
Hi,
Sorry to use comments for a call for help but I’m struggling. Installed the sdk, and python (which seems fine when I check it via terminal), but when I go to install pycrypto via the terminal I end up with this:
-bash: cd/Users/AronsonHome/Desktop/pycrypto2.1.0: No such file or directory
Any idea? The folder is there (I’ve tried it with the folder in Downloads and on the Desktop) but it won’t change the directory over to the folder so I can begin to install.
@Mike I assume you have the pycrypto folder on your desktop. I know this is a dumb question but are you typing in the exact name of the directory? Is it possibly named something different?
@Jane: No such thing…but I’m just dragging it into the terminal like you suggested so it should be alright. Just for kicks I just tried typing it in by hand, and then once again renaming the folder, no dice.
@Mike: This is another stupid question from me because I am not very technologically proficient but why are you typing -bash? Shouldn’t you just type cd?
@Jane: That’s not there when I originally type it in, only after hitting return, I assumed it was part of the error message.
@Mike: I can’t understand why you can’t rename your folder. Do you have administrative privileges on your Mac? Meoskop says you have to do this from the main account.
Hmm, I only have one account for this machine. Although this is the machine I use to sync my ipad (I’m trying this so I can borrow library books for my daughter for a roadtrip) I think I’ll try to get it working on my work machine tomorrow. Stay tuned (and thanks for the help)!
See if the link in comment # 60 meets your needs.
Anybody…. got to the stage where the automated INEPT EPUB decrypter offers me three choices. I insert this as instructed and the response is “No such file or directory”
Help…. please
What I do is copy and paste the book I want to the folder that I created for Python, and save to that same folder. I use the tool, saving to that same directory, and then move the book to my regular books folder. Be aware that you will not be able to use the tool on all epub books. I have a few of mine in which the tool does not work.
When I run ineptkey.py, I get the following error:
Traceback (most recent call last):
File “/Users/patrickreagan/Downloads/ineptkey.py”, line 31, in
from ctypes import windll, c_char_p, c_wchar_p, c_uint, POINTER, byref, \
ImportError: cannot import name windll
I’m running Mac OS X 10.6.3 and the install detailed above ran perfectly, but I cannot get my personal key. Help, please!
Patrick, did you try the link in comment #60 as a work-around?
@David: Thanks for the quick reply. However, when I try to use the workaround, “open with” does not allow me to use Preview.app. The file I am working with is a Adobe Digital Editions Document.
@kj:
Hi, I still have no luck to build and install the pyCrypto in my Mac OS Leopard. can you help me ?
this is what happened when i type build :
running build
running build_py
running build_ext
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
building ‘Crypto.Hash.MD2’ extension
gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/MD2.c -o build/temp.macosx-10.3-fat-2.6/src/MD2.o
unable to execute gcc-4.0: No such file or directory
error: command ‘gcc-4.0’ failed with exit status 1
I am having the same problem as Mike in comment #65. I download PyCrypto from the above link and drag it to my desktop. Then I open it so a folder appears on my desktop. I then open Terminal and type “cd” and drag the folder into the terminal screen. I then hit return and get “No such file or directory.” I also get the “-bash” that Mike was getting. I am an administrator for this computer so I am not sure why it is doing this. Any suggestions?
I kept getting the “no such file or directory” error too and and spent a lot of time researching how to correct that. A forum comment on mobileread.com from edembowski suggested downloading git. I then went to the pycrypto site and started with the directions under “Source Code.” From there it was pretty easy to get it all installed.
HELP NEEDED
Last login: Thu Jul 8 22:25:34 on ttys000
faith-abquinas-MacBook:~ faithabquina21$ cd
faith-abquinas-MacBook:~ faithabquina21$ /Users/faithabquina21/Downloads/pycrypto-2.1.0 python setup.py build
-bash: /Users/faithabquina21/Downloads/pycrypto-2.1.0: is a directory
faith-abquinas-MacBook:~ faithabquina21$ python setup.py install
/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can’t open file ‘setup.py’: [Errno 2] No such file or directory
faith-abquinas-MacBook:~ faithabquina21$
HELP PLS
what to do after git install?
@Monshinique: what to do after git installed?
@Jane: im on 81. please help me
@Faith Macadaan Abquina: I’m not an expert on these issues. My best advice is to delete and try again.
@Jane: i did.. couple of times still same error.. pls help me?
I’m sorry but I don’t know that I can help you.
@Estara: help me im no 81
This slight modification of the process worked for me on 10.6:
Instead of double-clicking on pycrypto-2.1.0 which you downloaded (which is actually pycrypt-2.1.0.tar.gz, but you may not see the .tar.gz if Finder is set up to hide known extensions) … copy the file from your Downloads folder to your home folder, e.g. (change this for your user name):
cp /Users/larry/Downloads/pycrypto-2.1.0.tar.gz ~
cd ~
tar -xvf pycrypto-2.1.0.tar.gz
(this will produce a folder called pycrypto-2.1.0)
cd pycrypto-2.1.0
python setup.py build
python setup.py install
If there are no error messages, you can delete the pycrypto-2.1.0 folder, and pycrypto-2.1.0.tar.gz.
HTH
Help!
Can anybody tell me why my MAC can’t find the file/directory after :
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 message: -bash:cd/Applications/pycrypto-2.1.0: No such file/directory computer :
@janine: Did you try the suggestion by commenter 80?
One person recommended downloading git.
Another Fink
If those two options don’t help, you might try MobileRead’s
@mike: I had the same exact error on Terminal what I ended up figuring out was that I needed to put a space in between the words cd and the name of the folder I was dragging into Terminal.
Thanks a lot, dude! I was really lost trying to install the Crypto package via Python’s “setup.py” – required MinGW, GMP and God knows what else.
Thank You to Jane for the original article and to Preeti for suggesting Viva Ebooks that helped me to un drm my legit ebooks so I can read them on my iphone.
I’m so grateful to both of you.
The whole drm thing just makes me love Baen even more for never using the horrible stuff on their ebooks.
I know it’s a little silly, but after I have successfully followed all the steps above, I don’t know what I am supposed to do now to strip the drm of my kindle books. Is there a step by step guide anywhere? The ones I find like http://www.dvdvideosoftware.org/guide/remove-drm-from-adobe-epub.html
are mostly for windows and confused me to no end… (I use a mac os X).
Really looking forward to someone who can help me. Thanks!
Thx for the forum. After much googling and noodling trying to get this to work I stumbled on this site — and the key was as a simple as installing the Xcode package. I was hung up for a long time on the “GMP library not found” error. In the end, that error still came up in the PyCrypto build phase, but doesn’t seem to matter. After the build, I ran the install script, and voila. I simply double clicked on the ineptkeymac.py app, specified the location for the .der file; then double-clicked the ineptpdf.pyw app and specified the in/out filenames. Bob’s my uncle.
The whole impulse behind this is not to copy books — but to free from the yoke of the ADE reader, which sucks.
I use a Mac.
Install was good and checked.
And now, how I use it to remove DRM from ePub ?
Very thanks.
… I got with “ineptepub.pyw” the decrypter window.
Key file : adeptkey.der
Input Path : A Folder with book.epub inside
Output Path : An other Folder
And I got
Error in: book.epub[Errno 2] No such file or directory :’/Users/hugo/Desktop/Books\\book.epub’
Thanks for your Help.
I bought a digital edition of a book from a store that advertised it as a PDF. I was expecting it to be readable in adobe acrobat. However it came with a .acsm extension so it wont open on anything except Adobe digital edition. I dont like reading on Digital Edition, I want it to open on Adobe Acrobat which I find a lot easier to use. Is there any way of working around the Digital Rights Management or atleast getting the file to open with acrobat by running the script that you talked about here. I dont want to reproduce the book, I just want to be able to read it in acrobat. I can see the file as a PDF, it just wont open like one
@annoyedbuyer: An encrypted PDF can only be read with Adobe Digital Editions. You’ll have to strip the DRM to read the PDF with Adobe Acrobat or Adobe Reader. There is an applescript that removes the DRM or you can google for a plugin for a free program called Calibre.
@Jane: thanks Jane! i’ll have a go at it.
Does this process work for pdf books that require a “user name” and “password”?
@Jane, Thank you very much! My wife had purchased B&N ebooks thinking she’d be able to read them on her sony ereader that I’d gotten her for christmas. I was lost with installing the python and pyccripto, until I found your post. All worked perfectly, and now her money didn’t go to waste! Again, Thank you!
This looks a bit outdated…..
For Mac OSX Snow Leopard…
* Install Xcode
* Install MacPorts http://www.macports.org/install.php
Once MacPorts is installed, install tk, pythonx.x and pyxx-tkinter (where xx is the majorminor version of the python version (as in 2.7 or 3.1) and gmp. there was an issue with pyxx-tkinter so you have to install separately, and as this provides the gui, don’t forget this step.) These are all installed with “sudo port install yyyy” where yyyy is the port to be installed.
* Now download the current version of PyCrypto and build (don’t forget to use sudo for this as well, as in “sudo pythonx.x setup.py install”
Lastly, mac ports puts python in /opt/local, so you need to
* make sure that you have a .profile that points to the proper bins
AND unless you want to invoke python as python2.7,
* you need to create a link from /opt/bin/python2.7 to python
Now you are good to go
@Marc Grober: Thanks for this. I keep getting an error when I try the first way. Can you explain it in a more simple way for us new mac users? Thanks.
@TEC – actually, the easiest way to manage all this is to use the Calibre plugins that Alf has published here http://www.datafilehost.com/download-aa179896.html and discusses here http://apprenticealf.wordpress.com/ You just need to download the tools from the first link, install calibre (http://calibre-ebook.com/download), and then install the plugins (start calibre, click on the gears icon and scroll down to the “advanced setion and click on the plugin icon-click on add and browse to the “tools” folder from the alf download and you will find a “Calibre_plugins” folder with the plugins – don’t unzip them, just add them one at a time – there are readme files for each plugin that tells you how to configure the plugins.)
But, if you want to run the scripts from python then the easiest way is to install Xcode from your DVD set (forget about 10.4 support but include X11), and then install macports ( get the installer package – dmg file- for your OS from http://www.macports.org/install.php )
Once macports is installed then install the packages mentioned using the appropriate commands – here is an example for the nmap package, which you don’t need, but it is the example in the manual, so….. http://guide.macports.org/#using.port.install
I have been told that if you install py27-crypto (as in
Macbook:yourdirectory$ sudo port install py27-crypto
you will not need anything else (it will install pycrypto for you), but I am unsure whether this will include tkinter, which you need if you want to use some of the scripts that employ a GUI…. so you can try it, and if the gui does not come up install pyt27-tkinter per my notes above… Otherwise, install the packages identified from MacPorts (python2.7, tk, py27-tkinter, gmp and python_select) and then download and install the latest version pycrypto from http://www.dlitz.net/software/pycrypto/ (its at 2.3 now) and install as Jane suggests (cd to the downloaded folder and “sudo python2.7 setup.py install”
Now python scripts can be run from the terminal by entering “python2.7 yourscript.py”. Of course you can you python_select to select the python2.7 envirnoemtn over the 2.6 that Apple provides, or you can
$cd /opt/local/bin
$ln -s python2.7 python
Let me know what specifics are unclear – things will make more sense if you look at my comments while you work through the steps.
@Marc Grober: Thanks so much for your fast reply on this! I did try the first option and it worked on my new books that I purchased from Kindle. Unfortunately somehow in the process my 134 books that came on my Sony reader when I bought it used on ebay will not open now. I haven’t had much time to mess with it. Any suggestions would be appreciated. Thanks again for your help!
@TEC not sure what you mean by “first way”….. As I understand it Sony now offers epubs only and uses Adobe ADEPT so you need to use the tool appropriate for that system – that would mean the ineptepub plugin for calibre or the appropriate python script from I <3 Cabbages (which is included in the ApprenticeAlf tools mentioned above.) I don't know why your pre-existing sony books won't open if you haven't messed with them….
If you have Python installed, the ‘Apprentice Alf’ package works like a charm, no need to install Macports and Pycrypto.
Thanks for this page Jane.
I had a problem installing with Xcode 4 on Lion 10.7.1, GMP not found error, had to remove other python versions and install this one : Python 2.7.2 Mac OS X 64-bit/32-bit x86-64/i386 Installer with pycrypto version 2.3. and this worked for me.
Is there a script to remove DRM from an epub book purchased from iTunes? I seem to have everything installed properly and working. I am able to generate an “adeptkey.der” for my purchased book. However when I run inept epub decrypter I get the error message “not an adept epub”. Any thoughts? Is it possible that the script is for Adobe “Epub” & not Apple “epub”? Is there a difference in the two scripts? Does anyone know where to find the Apple script? My Google searches keep returning only the Adobe script (same spelling). This has now become a matter of principal for me after reading all the posts & working at this for the better part of a week now in order to get to this point. (Forget the Advil – pass the Vicoden)
I also had problems installing Pycrypto as described above in the drag & drop process. However I noticed with the drag & drop there was no space between the ‘CD’ & the path. I then typed “CD”, hit the spacebar once & then dragged & dropped. Installed perfectly. I hope this might help some who are having problems or that come after me.
Thanks so very, very much for your website. I never would have gotten this far this quick without it.
@rickhawk4 – I don’t think there is a script to remove DRM from iBookstore books.
This article is somewhat dated as removing DRM is best done via calibre and plugins for calibre. No need for python or pycrypto.
@Marc Grober: Does it works with os 10.5.8??
@TEC: Problably your books on the sony reader only can be opened if you use the key user from the old owner…. the person who bought those e-books…
Does anyone have a solution to Hugo’s issue at point 100/101? I loaded pycrypto just fine but when I tried to launch ineptkeymac.py via terminal I get the same error message as Hugo did. Need a step by step for the next stage if anyone can spare it?
The mac instructions no longer seem to work.
Traceback (most recent call last):
File “setup.py”, line 456, in
core.setup(**kw)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py”, line 152, in setup
dist.run_commands()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 953, in run_commands
self.run_command(cmd)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py”, line 573, in run
self.run_command(‘build’)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py”, line 326, in run_command
self.distribution.run_command(command)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py”, line 127, in run
self.run_command(cmd_name)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py”, line 326, in run_command
self.distribution.run_command(command)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “setup.py”, line 251, in run
self.run_command(cmd_name)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py”, line 326, in run_command
self.distribution.run_command(command)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py”, line 972, in run_command
cmd_obj.run()
File “setup.py”, line 278, in run
raise RuntimeError(“autoconf error”)
RuntimeError: autoconf error