pyperclip: Error on Windows: OSError: exception: access violation writing 0x0000000000000000
I would like to use pyperclip to copy to clipboard and paste from it, but it seems that it is not working.
When I try to use pyperclip.copy("some string")
, I get the following errors:
Traceback (most recent call last): File “C:\Program Files\Python 3.5\lib\site-packages\pyperclip__init__.py”, line 68, in winSetClipboard ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text)) TypeError: string argument without an encoding
During handling of the above exception, another exception occurred: Traceback (most recent call last): File “<pyshell#2>”, line 1, in <module> pyperclip.copy(“hello”) File “C:\Program Files\Python 3.5\lib\site-packages\pyperclip__init__.py”, line 71, in winSetClipboard ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pchData), bytes(text, ‘ascii’)) OSError: exception: access violation writing 0x0000000000000000
On the other hand, when I use pyperclip.paste()
even if I had copied something previously, I get nothing printed, and even sometimes python crashes.
I am using windows 10 and python 3.5. I have also tried with python 3.4.3.
I have asked a question on [StackOverflow][http://stackoverflow.com/questions/32763044/pyperclip-module-not-working], and someone suggested to use pyperclip.copy(b"somestring"), and in this case I just get the second error. After informing this result, he suggested to report this as an issue, so this is it.
Thanks in advance.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20 (3 by maintainers)
Commits related to this issue
- Fix for issue #25: major problem with Pyperclip on Windows. — committed to asweigart/pyperclip by asweigart 9 years ago
- Set argument types to fix issue #25 Explicitly set the argument and return types of the clipboard functions used in the module. This fixed the error described in issue #25 on my computer. The problem... — committed to hinlader/pyperclip by hinlader 9 years ago
- Fix py3.5-x64 win clipboard. See https://github.com/asweigart/pyperclip/issues/25. — committed to kivy/kivy by matham 8 years ago
Okay, so I was able to repro this problem in 3.5 on Windows 7. I’ve changed the code so that 0 is passed to OpenClipboard in all cases (and it never passes None). This works for 2.6, 2.7, 3.1 through 3.5 on my Windows 7 box. Please update me if this problem still exists.
I haven’t contacted python core team about this issue, so I don’t know if there’s a bug report open on it. I’m mostly focused on getting pyperclip to work.