BoboTiG / python-mss

An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
https://pypi.org/project/mss/
MIT License
1.01k stars 93 forks source link

Support request: macOS Big Sur #178

Closed jack-ditto closed 4 years ago

jack-ditto commented 4 years ago

General information:

Description of the warning/error

When trying to use MSS, such as I am in the following code

mon = {'top': 160, 'left': 160, 'width': 200, 'height': 200}

sct = mss()

while 1:
    sct.get_pixels(mon)
    img = Image.frombytes('RGB', (sct.width, sct.height), sct.image)
    cv2.imshow('test', np.array(img))
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

You get an error: mss.exception.ScreenShotError: No CoreGraphics library found. This is because in Big Sur, dynamic libraries that are included in the OS are no longer present in the file system and can only be found by trying to open them with dlopen(). As an example:

>>> p = "/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/CoreFoundation"
>>> os.path.exists(p)
False
>>> cffi.FFI().dlopen(p)
<cffi.api.FFILibrary_/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/CoreFoundation object at 0x10f02b590>

Full message

    Traceback (most recent call last):
  File "main-mss.py", line 8, in <module>
    sct = mss()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mss/factory.py", line 36, in mss
    return darwin.MSS(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mss/darwin.py", line 77, in __init__
    raise ScreenShotError("No CoreGraphics library found.")
mss.exception.ScreenShotError: No CoreGraphics library found.
BoboTiG commented 4 years ago

Hello,

Thanks for the report. Unfortunately, I do not have a machine with Big Sur for now. I would also wait and see for https://bugs.python.org/issue41100, maybe will this be handled at the source.

But in any cases, there will still need a patch for Python versions < 3.8 ... And I would prefer to not having to rely on an external module to make MSS work.

Do you mind proposing a PR? If you can't, no worry, I will have a look when I could.

cjkumar commented 3 years ago

I also have this exact same issue since upgrading to big sur

BoboTiG commented 3 years ago

It works, just update MSS to the latest version.

cjkumar commented 3 years ago

"pip install --upgrade mss" Solved it for me Thank you @BoboTiG