ModuleNotFoundError:没有带有屏幕截图实用程序的名为“ fcntl”的模块

时间:2019-01-31 14:38:25

标签: python-3.x windows pyqt5 screenshot xlib

从以下位置移植后,我试图使屏幕截图实用程序正常工作

PyQt4       ->  PyQt5
Python 2.7  ->  Python 3.7
Ubuntu      ->  Windows 7

original code

new ported code

enter image description here

我将所有Qt4引用都更改为Qt5,并且除了Select Area功能之外,它都可以正常工作,该功能可以通过绘制矩形在屏幕上选择区域。这部分失败,并显示以下错误:

resArea: Traceback (most recent call last):
  File "screenshot.py", line 318, in <module>
    d = display.Display()
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\display.py", line 89, in __init__
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\display.py", line 71, in __init__
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\protocol\display.py", line 85, in __init__
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\connect.py", line 72, in get_display
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\connect.py", line 55, in _relative_import
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\unix_connect.py", line 31, in <module>
ModuleNotFoundError: No module named 'fcntl'    

我知道Windows不支持fcntl,但是我认为这可能是一种解决方法,因为我认为代码要执行的工作是在继续操作之前获取一些屏幕尺寸。

到目前为止,我所做的所有研究都将我引向pyscreenshot之类的其他事物,或其他只能实现全屏抓图但没有矩形选择器来选择屏幕区域的替代实现。

我喜欢这种实现方式,因为它向您显示了快速预览以及选择区域,调整延迟,隐藏窗口并保存到文件的选项。

任何帮助将不胜感激

0 个答案:

没有答案