Unable to import NS* classes from Cocoa/Appkit

Issue #211 invalid
Anush Jayaraman
created an issue

Hello, I tried to use the searchKit example after installing pyobjc and my IDE is not able to resolve Cocoa.NSObject. Also, I'm unable to import NSworkspace from AppKit. Is this not supported anymore? Do I need to install any modules other than pyobjc? I'm fairly new to this and trying to write a simple app to work on Mac os sierra (10.12.16) (running latest pyobjc). Any suggestions would be helpful.

Comments (6)

  1. Ronald Oussoren repo owner

    Cocoa.NSObject is still supported and you don't have to install anything beyond "pip install pyobjc". I'm not sure what your problem is.

    • What is the IDE you use?

    • What do you mean by "my IDE is not able to resolve Cocoa.NSObject"?

    PyObjC does use a lazy initialisation for the framework wrappers (such as the Cocoa module), maybe that confuses your IDE.

  2. Anush Jayaraman reporter

    @Ronald Oussoren Thanks for your response. I'm using pycharm. After importing Cocoa, my IDE throws an error saying Cannot find reference in init.py of Cocoa.NSobject.

    Also pip install appkit gave an error which threw me off -- Collecting appkit Using cached AppKit-0.2.8.tar.gz Collecting flask (from appkit) Using cached Flask-0.12.2-py2.py3-none-any.whl Collecting pygobject (from appkit) Could not find a version that satisfies the requirement pygobject (from appkit) (from versions: ) No matching distribution found for pygobject (from appkit)

    Let me try importing using an interpreter outside of the IDE.

  3. Ronald Oussoren repo owner

    "pip install appkit" tries to install something that isn't part of PyObjC, "pip install pyobjc-framework-Cocoa" installs the AppKit bindings for PyObjC (although I'd just use "pip install pyobjc").

  4. Log in to comment