mouse icon indicating copy to clipboard operation
mouse copied to clipboard

[BUG] `ImportError` while installing the (pre-release) package on macOS

Open lnxpy opened this issue 2 years ago • 1 comments

When I'm trying to install the package on macOS Ventura 13.4.1, I get the following exception.

$ pip install git+https://github.com/boppreh/mouse.git

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "<pip-setuptools-caller>", line 34, in <module>
  File "/private/tmp/mouse/setup.py", line 7, in <module>
    import mouse
  File "/private/tmp/mouse/mouse/__init__.py", line 57, in <module>
    from. import _darwinmouse as _os_mouse
  File "/private/tmp/mouse/mouse/_darwinmouse.py", line 6, in <module>
    import Quartz
ModuleNotFoundError: No module named 'Quartz'

My solution

That's basically because you're importing mouse in setup.py. It actually triggers the __init__.py to run and in the OS condition during the installation process, it tries to from. import _darwinmouse as _os_mouse which needs Quartz (which is one of the dependencies) to be already installed.

To fix the issue, simply remove import mouse line from setup.py and satisfy the values of version and long_description from another source out of the mouse/ directory. Or you can read the actual context of <package>/<package>/__init__.py file and apply a RegEx pattern to find out the value of version from within the setup.py file which I don't recommend.

Both solutions will fix the issue for Mac users.

lnxpy avatar Jul 18 '23 02:07 lnxpy

Thank you for the solution! I ran into this trouble as well, and I solved it by simply replacing the version with '0.7.1' and commenting out the long_description line.

JerryWeii-27 avatar Mar 01 '24 10:03 JerryWeii-27