Forums

Pyperclip requires the ....

I'm running through some exercises in a new book on Python ("Automate the Boring Stuff with Python....") and it requires a module, pyperclip, which I dutifully imported using

pip3.4 import --user pyperclip #I am using python 3.4

The import appeared to work, but when I attempted to import pyperclip, I got the following:

import pyperclip Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/adavidow/.local/lib/python3.4/site-packages/pyperclip/init.py", line 203, in <module> raise Exception('Pyperclip requires the xclip or xsel application, or the gtk or PyQt4 module.') Exception: Pyperclip requires the xclip or xsel application, or the gtk or PyQt4 module.

Help?

I think you will struggle to get that working on PythonAnywhere as it appears to be a GUI tool - PyQT, xclip and xsel are all related to windowing stuffing.

@rcs1000 is right -- pyperclip wants to be able to access your local computer's clipboard, and it won't be able to do that from the PythonAnywhere servers. You'll have to install Python and pyperclip on your own PC to get those particular parts of the book working...

How are you enjoying that book? I got a review copy myself the other day :)

The book is good! A lot of fun. Not too many typos.

Yeah, it gradually occurred to me that this didn't make sense in the pythonanywhere environment.

Hi adavidow! This is Al the author. I can confirm that, yes, pyperclip only works if you are running Python programs on your local computer. It doesn't make sense to use it on a server environment like PythonAnywhere.

The second printing will be done soon and gets rid of a lot of typos that people have sent us. Feel free to email me if you find others. al@inventwithpython.com

Thanks!

I emailed a few errata to your publisher, earlier. Really enjoying the book, although have to sit down with it at irregular intervals as I have time.

One minor issue is that in Appendix B you list all python modules that need to be installed, but don't list pyperclip--probably should be there, although installing it on my desktop and laptop was among the least challenges.

I'll email a few others that I haven't yet reported, although you've probably already heard from others.

That's great! Can you forward me the errata so I can update the website (I manage it, rather than No Starch Press). al@inventwithpython.com

(Oh, I just noticed you had already emailed me. Thanks!)

Done. Just sent earlier errata