asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.64k stars 195 forks source link

PyQt4 broken on Ubuntu #67

Open orlp opened 8 years ago

orlp commented 8 years ago

The PyQt4 implementation is broken on Ubuntu 14.04, but I don't necessarily think it's pyperclips fault:

~/ λ python3                                                                                                                                                              
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4.QtGui import QApplication
>>> QApplication([]).clipboard().setText("test")
[1]    2441 segmentation fault (core dumped)  python3

Either way, I would really prefer it if xclip was prioritized over PyQt4, and/or being able to blacklist implementations in the preference list.

brbsix commented 7 years ago

Getting the clipboard to work with PyQt4 on Ubuntu is going to require starting the event loop (e.g. app.exec_). I looked into a few courses of action like running processEvents after each operation, or performing the clipboard operations on another thread using postEvent (for an example, see https://github.com/autokey/autokey/blob/master/src/lib/scripting.py#L793) but wasn't able to find a satisfactory solution before giving up. Hopefully someone more familiar with PyQt on X11 can offer one but it doesn't look promising.

m-beau commented 6 years ago

Hi there,

I encounter a similar issue when trying to run PyQt4 on ubuntu 16.04 native Python3.

Check that out (details printed out with the faulthandler module):

~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faulthandler
>>> faulthandler.enable()
>>> import PyQt4.QtCore
Fatal Python error: Segmentation fault

Current thread 0x00007fd543ee2700 (most recent call first):
  File "<frozen importlib._bootstrap>", line 222 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 906 in create_module
  File "<frozen importlib._bootstrap>", line 577 in module_from_spec
  File "<frozen importlib._bootstrap>", line 666 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 958 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 969 in _find_and_load
  File "<stdin>", line 1 in <module>
Segmentation fault (core dumped)

This error does not occur when doing the same import on Python2. I need to work with this very version of PyQt4 (4.x, not 5.x) because I need to use the QtCore module.

I am quite new to the tech world so this is very obscure to me, any help would be greatly appreciated :)

Cheers

m-beau commented 6 years ago

Any update @chocolateboy ?