moses-palmer / pystray

GNU General Public License v3.0
463 stars 57 forks source link

Mac OSX Big Sur problems #76

Closed AndreMPCosta closed 3 years ago

AndreMPCosta commented 3 years ago

When I'm trying to use pystray I get this traceback:

Traceback (most recent call last):
  File "/Users/andrecosta/Repositories/ManageKeepass/sync.py", line 135, in <module>
    icon.menu = Menu(
  File "/Users/andrecosta/.local/share/virtualenvs/ManageKeepass-AG3eVfMG/lib/python3.9/site-packages/pystray/_base.py", line 141, in menu
    self.update_menu()
  File "/Users/andrecosta/.local/share/virtualenvs/ManageKeepass-AG3eVfMG/lib/python3.9/site-packages/pystray/_base.py", line 216, in update_menu
    self._update_menu()
  File "/Users/andrecosta/.local/share/virtualenvs/ManageKeepass-AG3eVfMG/lib/python3.9/site-packages/pystray/_darwin.py", line 73, in _update_menu
    nsmenu = self._create_menu(self.menu, callbacks)
  File "/Users/andrecosta/.local/share/virtualenvs/ManageKeepass-AG3eVfMG/lib/python3.9/site-packages/pystray/_darwin.py", line 194, in _create_menu
    self._create_menu_item(descriptor, callbacks))
  File "/Users/andrecosta/.local/share/virtualenvs/ManageKeepass-AG3eVfMG/lib/python3.9/site-packages/pystray/_darwin.py", line 223, in _create_menu_item
    menu_item.setTarget_(self._delegate)
AttributeError: 'Icon' object has no attribute '_delegate'

I've installed pyobjc before running, because I would face this issue: ImportError: this platform is not supported: No module named 'AppKit'

AndreMPCosta commented 3 years ago

I'm running Catalina 10.15.7 and I still have the same issue. I don't think this is related to Big Sur necessarily

I've switched to rumps when I'm on OS X, I'm using pystray in my Windows Machine.

moses-palmer commented 3 years ago

I have finally acquired access to macOS. Unfortunately, I cannot reproduce this error. My attempt is as follows:

# Prepare
git clone git@github.com:moses-palmer/pystray
python3 -m venv pystray/venv/macos

# Install
cd pystray
. venv/macos/bin/activate
pip install wheel
python setup.py develop

# Test
cp $SOME_SCRIPT_USING_PYSTRAY ./test.py
python test.py

This is on Catalina 10.15.7 according to sw_vers.

moses-palmer commented 3 years ago

Could it be Quartz=3.0 that is incompatible with Big Sur?

I have pushed a test branch to fixup-macos-quartz-version. Is it possible for you to test it, @AndreMPCosta or @sanylax?

AndreMPCosta commented 3 years ago

Sorry, I've moved to rumps, it was just an heads up about this issue.

AndreMPCosta commented 3 years ago

@moses-palmer I've tried to use it on a new project but I'm not being successful installing:

`Error: An error occurred while installing -e git+https://github.com/moses-palmer/pystray.git@fixup-macos-quartz-version#egg=pystray! Error text: Obtaining pystray from git+https://github.com/moses-palmer/pystray.git@fixup-macos-quartz-version#egg=pystray (from -r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) Cloning https://github.com/moses-palmer/pystray.git (to revision fixup-macos-quartz-version) to /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray Requirement already satisfied: Pillow in /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages (from pystray->-r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) (8.1.0) Requirement already satisfied: six in /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages (from pystray->-r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) (1.15.0) Requirement already satisfied: pyobjc-framework-Quartz>=7.0 in /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages (from pystray->-r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) (7.1) Requirement already satisfied: pyobjc-core>=7.1 in /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages (from pyobjc-framework-Quartz>=7.0->pystray->-r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) (7.1) Requirement already satisfied: pyobjc-framework-Cocoa>=7.1 in /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages (from pyobjc-framework-Quartz>=7.0->pystray->-r /var/folders/tr/3v_lvk4s1ygg_hxty4h_mhhc0000gn/T/pipenv-y3aea9-requirements/pipenv-qgchmrs0-requirement.txt (line 1)) (7.1) Installing collected packages: pystray Running setup.py develop for pystray

ERROR: Command errored out with exit status 1:
 command: /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/setup.py'"'"'; __file__='"'"'/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
     cwd: /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/
Complete output (27 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/setup.py", line 81, in <module>
    setuptools.setup(
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/__init__.py", line 152, in setup
    _install_setup_requires(attrs)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/dist.py", line 673, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/pkg_resources/__init__.py", line 764, in resolve
    dist = best[req.key] = env.best_match(
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1049, in best_match
    return self.obtain(req, installer)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1061, in obtain
    return installer(requirement)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/dist.py", line 732, in fetch_build_egg
    return fetch_build_egg(self, req)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/installer.py", line 131, in fetch_build_egg
    wheel.install_as_egg(dist_location)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/wheel.py", line 95, in install_as_egg
    self._install_as_egg(destination_eggdir, zf)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/wheel.py", line 103, in _install_as_egg
    self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
  File "/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/lib/python3.9/site-packages/setuptools/wheel.py", line 124, in _convert_metadata
    os.mkdir(destination_eggdir)
FileExistsError: [Errno 17] File exists: '/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/.eggs/MarkupSafe-1.1.1-py3.9-macosx-10.9-universal2.egg'
----------------------------------------

ERROR: Command errored out with exit status 1: /Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/setup.py'"'"'; file='"'"'/Users/andrecosta/.local/share/virtualenvs/DiscordHotkey-J6RvRmJD/src/pystray/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output. ✘ Installation Failed `

moses-palmer commented 3 years ago

@AndreMPCosta, thannk you fortd sorry for the long delay.

Yeah, I had severe issues as well to install it on macOS, but I experienced the same errors trying to install almost any pip package on that operating system. I had to remove the offending file, try again, have it fail in some other way, until it would finally randomly work.

In any case, I have merged the test branch into master with the assumption that it works, and I will close this issue. @sanylax, if you find that the problem is not resolved, please reopen this issue.