deanishe / zothero

Rapidly search and cite Zotero entries from Alfred
MIT License
480 stars 31 forks source link

Now, MacOS 12.3 is released. Zothero cannot work on it. #70

Open zzhanghub opened 2 years ago

zzhanghub commented 2 years ago

The workflow does not work anymore due to the removal of Python 2.

Miaoyifei-mz commented 2 years ago

I reinstalled Python 2, Zothero still cannot work.

Miaoyifei-mz commented 2 years ago

That could be one solution:https://www.alfredforum.com/topic/17941-making-python-2-workflows-work-on-macos-monterey-123-and-above/page/2/#comments

Miaoyifei-mz commented 2 years ago

I reinstall zothero from this, it works. But zotconf don't work.

[15:08:45.332] ZotHero[Script Filter] Queuing argument ''
[15:08:45.341] ZotHero[Script Filter] Script with argv '' finished
[15:08:45.344] ERROR: ZotHero[Script Filter] Code 127: env: python: No such file or directory
moffat commented 2 years ago

Take a look at this: https://github.com/willemml/alfred-convert#macos-123-and-later

I can make most of zothero work using the solution above. You do need to find instanced in the code where /usr/bin/python is being called directly, and change it to the pyenv version.

In order to get the copy references command to work, I had to install PyObjC in the pyenv environment I set up with pip install PyObjC

Miaoyifei-mz commented 2 years ago

@moffat Can you use zotconf ? I tried it your way, but still cannot use zotconf.If it's convenient, could you share your modified version? Thank you very much!

lecoan commented 2 years ago

@moffat Can you use zotconf ? I tried it your way, but still cannot use zotconf.If it's convenient, could you share your modified version? Thank you very much! I had the same problem as you. It seems like a pickle version issue and I made the following change to lib/workflow/workflow.py:

#self._cache_serializer = 'cpickle'
self._cache_serializer = 'json'
#self._data_serializer = 'cpickle'
self._data_serializer = 'json'

now, zotconf works

Miaoyifei-mz commented 2 years ago

@lecoan Thank you! Zotconf can work by your way 😊. There is still one small problem, when I select a paper item and press command+enter or option+enter to copy the citations, citations don't appear on the clipboard. Zothero doesn't seem to be working.

lecoan commented 2 years ago

@lecoan Thank you! Zotconf can work by your way 😊. There is still one small problem, when I select a paper item and press command+enter or option+enter to copy the citations, citations don't appear on the clipboard. Zothero doesn't seem to be working.

I didn't meet this problem. Do you set the default style with zotconf and set the COPY_CITEKEY_MOD? when you changed the _xx_serializer, the configuration needs to be set again.

Miaoyifei-mz commented 2 years ago

@lecoan I set the default style with zotconf, and don't set the COPY_CITEKEY_MOD. The problem still exists.

moffat commented 2 years ago

My understanding of the code is that copying references requires that the python environment you're using to replace the system one has 'pyobjc' installed so that it can interact with the system's pasteboard.

In my case I used 'pyenv' to make sure that package was installed.

Keep an eye on the log entries when you're running Zothero. The errors you get there should be informative.

lecoan commented 2 years ago

@Miaoyifei-mz Yes, pyobjc is essential for zothero, and I also modified the info.plist file in the workflow folder to use cmd+enter to copy the cite key.

    <key>COPY_CITEKEY_MOD</key>
    <string>cmd</string> 

If you still face problems, you can paste the debug log here from alfred.

Miaoyifei-mz commented 2 years ago

@lecoan hello, the problem still exists when I copy citations. I have installed PyObjC with pip install PyObjC, and here is the debug log:

[10:15:05.297] STDERR: ZotHero[[Run Script](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.8B964301-D7F8-4370-9720-5C0072DA80B9%3EA950947F-8EA7-4749-AF55-2C7F9D6E695E)] .
10:15:05 workflow.py:2061 DEBUG    ---------- ZotHero (1.3.0) ----------
10:15:05 workflow.py:1468 DEBUG    reading settings from /Users/zhuangzhu/Library/Application Support/Alfred/Workflow Data/net.deanishe.alfred.zothero/settings.json
10:15:05 workflow.py:2343 DEBUG    update check not due
10:15:05 zh:667 DEBUG    args={'--bibliography': False,
 '--help': False,
 '--paste': False,
 '--style': None,
 '--text': None,
 '--title': None,
 '<citekey>': None,
 '<id>': u'401',
 '<key>': None,
 '<query>': None,
 '<style>': u'http://juris-m.github.io/jm-styles/jm-chinese-gb7714-2005-numeric',
 '<value>': None,
 'attachments': False,
 'citations': False,
 'clear': False,
 'config': False,
 'copy': True,
 'fields': False,
 'locale': False,
 'notify': False,
 'reindex': False,
 'search': False,
 'setvar': False,
 'style': False}
10:15:05 config.py:85 DEBUG    [config] datadir=u'/Users/zhuangzhu/Zotero'
10:15:05 core.py:72 DEBUG    [core] cachedir=u'~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/net.deanishe.alfred.zothero'
10:15:05 core.py:73 DEBUG    [core] zotero_dir=u'~/Zotero'
10:15:05 core.py:74 DEBUG    [core] attachments_dir=None
10:15:05 workflow.py:2080 ERROR    No module named AppKit
Traceback (most recent call last):
  File "./lib/workflow/workflow.py", line 2073, in run
    func(self)
  File "./zh", line 702, in main
    args['--paste'])
  File "./zh", line 339, in do_copy
    import pasteboard as pb
  File "./lib/pasteboard.py", line 14, in <module>
    from AppKit import NSPasteboard
ImportError: No module named AppKit
10:15:05 workflow.py:2082 INFO     for assistance, see: https://github.com/deanishe/zothero/issues
10:15:05 workflow.py:2103 DEBUG    ---------- finished in 0.017s ----------
zzhanghub commented 2 years ago

@lecoan hello, the problem still exists when I copy citations. I have installed PyObjC with pip install PyObjC, and here is the debug log:

[10:15:05.297] STDERR: ZotHero[[Run Script](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.8B964301-D7F8-4370-9720-5C0072DA80B9%3EA950947F-8EA7-4749-AF55-2C7F9D6E695E)] .
10:15:05 workflow.py:2061 DEBUG    ---------- ZotHero (1.3.0) ----------
10:15:05 workflow.py:1468 DEBUG    reading settings from /Users/zhuangzhu/Library/Application Support/Alfred/Workflow Data/net.deanishe.alfred.zothero/settings.json
10:15:05 workflow.py:2343 DEBUG    update check not due
10:15:05 zh:667 DEBUG    args={'--bibliography': False,
 '--help': False,
 '--paste': False,
 '--style': None,
 '--text': None,
 '--title': None,
 '<citekey>': None,
 '<id>': u'401',
 '<key>': None,
 '<query>': None,
 '<style>': u'http://juris-m.github.io/jm-styles/jm-chinese-gb7714-2005-numeric',
 '<value>': None,
 'attachments': False,
 'citations': False,
 'clear': False,
 'config': False,
 'copy': True,
 'fields': False,
 'locale': False,
 'notify': False,
 'reindex': False,
 'search': False,
 'setvar': False,
 'style': False}
10:15:05 config.py:85 DEBUG    [config] datadir=u'/Users/zhuangzhu/Zotero'
10:15:05 core.py:72 DEBUG    [core] cachedir=u'~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/net.deanishe.alfred.zothero'
10:15:05 core.py:73 DEBUG    [core] zotero_dir=u'~/Zotero'
10:15:05 core.py:74 DEBUG    [core] attachments_dir=None
10:15:05 workflow.py:2080 ERROR    No module named AppKit
Traceback (most recent call last):
  File "./lib/workflow/workflow.py", line 2073, in run
    func(self)
  File "./zh", line 702, in main
    args['--paste'])
  File "./zh", line 339, in do_copy
    import pasteboard as pb
  File "./lib/pasteboard.py", line 14, in <module>
    from AppKit import NSPasteboard
ImportError: No module named AppKit
10:15:05 workflow.py:2082 INFO     for assistance, see: https://github.com/deanishe/zothero/issues
10:15:05 workflow.py:2103 DEBUG    ---------- finished in 0.017s ----------

You need to make sure you install PyObjC using a specific Python environment. 🤔

path_of_your_python2 -m pip install pyobjc
mgass commented 2 years ago

Installation of pyobjc is throwing an error for me:

ValueError: invalid literal for int() with base 10: ''

My error is similar to this bug they had 2 years ago. A parameter gets reduced to an empty string...

I have been able to use pyenv and install pypy2.7-7.3.6 to get zothero mostly working. But python2 -m pip install pyobjc fails during setup. Is anyone else seeing this? Is there a workaround?

tophee commented 2 years ago

Check this out:

https://github.com/alfredapp/updated-third-party-python2-workflows#workflows

Korean-David commented 2 years ago

Will Zothero be updated to be compatible with Mac 12.3? This is one of the most frequently used workflows for me, and I'm really looking forward to its update.

raykr commented 2 years ago

How to solve it in Apple Silicon M1 12.3?

simonleandergrimm commented 2 years ago

Flagging that this is still an issue

giovannicoppola commented 2 years ago

this fork is migrated to Python 3

raykr commented 2 years ago

this fork is migrated to Python 3

[15:57:56.738] ZotHero[[Script Filter](alfredpreferences:workflows%3Eworkflow%3Euser.workflow.1C7C9D93-5CEC-44C0-966D-F294641DF6E5%3E53172C76-0F6F-4E84-8C96-D0E81629CBA4)] {
  "items": [
    {
      "title": "Error in workflow 'ZotHero'",
      "subtitle": "__str__ returned non-string (type NoneType)",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

Apple Silicon M1 12.3

kzssc commented 2 years ago

on 12.4 and can confirm that this(https://github.com/alfredapp/updated-third-party-python2-workflows#readme) works, pay attention to footnotes 2 and 3

giovannicoppola commented 2 years ago

@RayKr the most recent version should fix this problem. let me know if you see anything else!

alexandergogl commented 2 years ago

@giovannicoppola thanks a lot for the fix! It works on OS 12.3.1. I am glad, that I don't need to install python 2 :)