Jump to content

Circular reference error: referencing 3rd party python library in local directory


Recommended Posts

Hi there

 

I'm trying to create a hot key based, media control workflow from this gist

 

Simulating how Alfred workflow will work:

1. creating a directory with the gist

2. getting the "pyobjc" package locally using 

Quote

pip3 install -U --target ./packages pyobjc

3. adding this line before the "import Quartz" line:

Quote

sys.path.append("./packages")

4. In my local directory, I run "python3 <python_file_name>.py playpause", and it works

 

When I do the same with the Workflow however, I get this error for the "import Quartz" statement

 

Quote

File "/Users/jz/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/7FBE5A9F-CF4A-46EA-B33A-5543450B6001", line 17, in <module>
    import Quartz
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./Quartz/__init__.py", line 47, in <module>
    globals().pop("_setup")()
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./Quartz/__init__.py", line 7, in _setup
    import AppKit
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./AppKit/__init__.py", line 148, in <module>
    globals().pop("_setup")()
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./AppKit/__init__.py", line 12, in _setup
    import Foundation
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./Foundation/__init__.py", line 188, in <module>
    globals().pop("_setup")()
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./Foundation/__init__.py", line 12, in _setup
    import CoreFoundation
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./CoreFoundation/__init__.py", line 37, in <module>
    globals().pop("_setup")()
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./CoreFoundation/__init__.py", line 12, in _setup
    import objc
  File "/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./objc/__init__.py", line 6, in <module>
    from . import _objc
ImportError: cannot import name '_objc' from partially initialized module 'objc' (most likely due to a circular import) (/Users/jz/Documents/MySettings/Alfred_v5_settings/Alfred.alfredpreferences/workflows/user.workflow.253A047C-F087-4F51-9627-D081AC2B831C/./objc/__init__.py)

 

The issue relates to the objc library which I haven't changed. 

Any idea what I'm doing wrong for this to work in Terminal, but not in an Alfred Workflow?

Thanks!

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...