ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
559 stars 46 forks source link

ImportError: cannot import name 'NSApplication' from 'Cocoa' #570

Closed TheBuzzer67 closed 1 year ago

TheBuzzer67 commented 1 year ago

Could be too ealy

Describe the bug Import problem with new version 10 all-examples/core/scripts/HelloWorld.py", line 25, in from Cocoa import NSObject, NSApplication, NSApp, NSWindow, NSButton, NSSound ImportError: cannot import name 'NSApplication' from 'Cocoa' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/Cocoa/init.py)

Platform information

To Reproduce python3 HelloWorld.py

Expected behavior Above error

Additional context Just updated to pyobjc 10 version with pip3 list --outdated | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U

ronaldoussoren commented 1 year ago

Could you check if everything was updated to 10.0? I had problems on my end uploading the release to PyPI (see #571), which I didn't notice at first.

TheBuzzer67 commented 1 year ago

Could you check if everything was updated to 10.0? I had problems on my end uploading the release to PyPI (see #571), which I didn't notice at first.

The only one I see at 9.2 is pyobjc-framework-IMServicePlugIn, could it be the problem?

Does your HelloWorld works?

pyobjc 10.0 pyobjc-core 10.0 pyobjc-framework-Accessibility 10.0 pyobjc-framework-Accounts 10.0 pyobjc-framework-AddressBook 10.0 pyobjc-framework-AdServices 10.0 pyobjc-framework-AdSupport 10.0 pyobjc-framework-AppleScriptKit 10.0 pyobjc-framework-AppleScriptObjC 10.0 pyobjc-framework-ApplicationServices 10.0 pyobjc-framework-AppTrackingTransparency 10.0 pyobjc-framework-AudioVideoBridging 10.0 pyobjc-framework-AuthenticationServices 10.0 pyobjc-framework-AutomaticAssessmentConfiguration 10.0 pyobjc-framework-Automator 10.0 pyobjc-framework-AVFoundation 10.0 pyobjc-framework-AVKit 10.0 pyobjc-framework-AVRouting 10.0 pyobjc-framework-BackgroundAssets 10.0 pyobjc-framework-BusinessChat 10.0 pyobjc-framework-CalendarStore 10.0 pyobjc-framework-CallKit 10.0 pyobjc-framework-CFNetwork 10.0 pyobjc-framework-ClassKit 10.0 pyobjc-framework-CloudKit 10.0 pyobjc-framework-Cocoa 10.0 pyobjc-framework-Collaboration 10.0 pyobjc-framework-ColorSync 10.0 pyobjc-framework-Contacts 10.0 pyobjc-framework-ContactsUI 10.0 pyobjc-framework-CoreAudio 10.0 pyobjc-framework-CoreAudioKit 10.0 pyobjc-framework-CoreBluetooth 10.0 pyobjc-framework-CoreData 10.0 pyobjc-framework-CoreHaptics 10.0 pyobjc-framework-CoreLocation 10.0 pyobjc-framework-CoreMedia 10.0 pyobjc-framework-CoreMediaIO 10.0 pyobjc-framework-CoreMIDI 10.0 pyobjc-framework-CoreML 10.0 pyobjc-framework-CoreMotion 10.0 pyobjc-framework-CoreServices 10.0 pyobjc-framework-CoreSpotlight 10.0 pyobjc-framework-CoreText 10.0 pyobjc-framework-CoreWLAN 10.0 pyobjc-framework-CryptoTokenKit 10.0 pyobjc-framework-DataDetection 10.0 pyobjc-framework-DeviceCheck 10.0 pyobjc-framework-DictionaryServices 10.0 pyobjc-framework-DiscRecording 10.0 pyobjc-framework-DiscRecordingUI 10.0 pyobjc-framework-DiskArbitration 10.0 pyobjc-framework-DVDPlayback 10.0 pyobjc-framework-EventKit 10.0 pyobjc-framework-ExceptionHandling 10.0 pyobjc-framework-ExecutionPolicy 10.0 pyobjc-framework-ExtensionKit 10.0 pyobjc-framework-ExternalAccessory 10.0 pyobjc-framework-FileProvider 10.0 pyobjc-framework-FileProviderUI 10.0 pyobjc-framework-FinderSync 10.0 pyobjc-framework-FSEvents 10.0 pyobjc-framework-GameCenter 10.0 pyobjc-framework-GameController 10.0 pyobjc-framework-GameKit 10.0 pyobjc-framework-GameplayKit 10.0 pyobjc-framework-HealthKit 10.0 pyobjc-framework-ImageCaptureCore 10.0 pyobjc-framework-IMServicePlugIn 9.2 pyobjc-framework-InputMethodKit 10.0 pyobjc-framework-InstallerPlugins 10.0 pyobjc-framework-InstantMessage 10.0 pyobjc-framework-Intents 10.0 pyobjc-framework-IntentsUI 10.0 pyobjc-framework-IOBluetooth 10.0 pyobjc-framework-IOBluetoothUI 10.0 pyobjc-framework-IOSurface 10.0 pyobjc-framework-iTunesLibrary 10.0 pyobjc-framework-KernelManagement 10.0 pyobjc-framework-LatentSemanticMapping 10.0 pyobjc-framework-LaunchServices 10.0 pyobjc-framework-libdispatch 10.0 pyobjc-framework-libxpc 10.0 pyobjc-framework-LinkPresentation 10.0 pyobjc-framework-LocalAuthentication 10.0 pyobjc-framework-LocalAuthenticationEmbeddedUI 10.0 pyobjc-framework-MailKit 10.0 pyobjc-framework-MapKit 10.0 pyobjc-framework-MediaAccessibility 10.0 pyobjc-framework-MediaLibrary 10.0 pyobjc-framework-MediaPlayer 10.0 pyobjc-framework-MediaToolbox 10.0 pyobjc-framework-Metal 10.0 pyobjc-framework-MetalFX 10.0 pyobjc-framework-MetalKit 10.0 pyobjc-framework-MetalPerformanceShaders 10.0 pyobjc-framework-MetalPerformanceShadersGraph 10.0 pyobjc-framework-MetricKit 10.0 pyobjc-framework-MLCompute 10.0 pyobjc-framework-ModelIO 10.0 pyobjc-framework-MultipeerConnectivity 10.0 pyobjc-framework-NaturalLanguage 10.0 pyobjc-framework-NetFS 10.0 pyobjc-framework-Network 10.0 pyobjc-framework-NetworkExtension 10.0 pyobjc-framework-NotificationCenter 10.0 pyobjc-framework-OpenDirectory 10.0 pyobjc-framework-OSAKit 10.0 pyobjc-framework-OSLog 10.0 pyobjc-framework-PassKit 10.0 pyobjc-framework-PencilKit 10.0 pyobjc-framework-PHASE 10.0 pyobjc-framework-Photos 10.0 pyobjc-framework-PhotosUI 10.0 pyobjc-framework-PreferencePanes 10.0 pyobjc-framework-PushKit 10.0 pyobjc-framework-Quartz 10.0 pyobjc-framework-QuickLookThumbnailing 10.0 pyobjc-framework-ReplayKit 10.0 pyobjc-framework-SafariServices 10.0 pyobjc-framework-SafetyKit 10.0 pyobjc-framework-SceneKit 10.0 pyobjc-framework-ScreenCaptureKit 10.0 pyobjc-framework-ScreenSaver 10.0 pyobjc-framework-ScreenTime 10.0 pyobjc-framework-ScriptingBridge 10.0 pyobjc-framework-SearchKit 10.0 pyobjc-framework-Security 10.0 pyobjc-framework-SecurityFoundation 10.0 pyobjc-framework-SecurityInterface 10.0 pyobjc-framework-ServiceManagement 10.0 pyobjc-framework-SharedWithYou 10.0 pyobjc-framework-SharedWithYouCore 10.0 pyobjc-framework-ShazamKit 10.0 pyobjc-framework-Social 10.0 pyobjc-framework-SoundAnalysis 10.0 pyobjc-framework-Speech 10.0 pyobjc-framework-SpriteKit 10.0 pyobjc-framework-StoreKit 10.0 pyobjc-framework-SyncServices 10.0 pyobjc-framework-SystemConfiguration 10.0 pyobjc-framework-SystemExtensions 10.0 pyobjc-framework-ThreadNetwork 10.0 pyobjc-framework-UniformTypeIdentifiers 10.0 pyobjc-framework-UserNotifications 10.0 pyobjc-framework-UserNotificationsUI 10.0 pyobjc-framework-VideoSubscriberAccount 10.0 pyobjc-framework-VideoToolbox 10.0 pyobjc-framework-Virtualization 10.0 pyobjc-framework-Vision 10.0 pyobjc-framework-WebKit 10.0 pyobjus 1.2.2 pyproject-toml 0.0.10

TheBuzzer67 commented 1 year ago

Examples Have to be updated too

TheBuzzer67 commented 1 year ago

I went through the install and those packages are not compatible with MacBookPro M1

Skipping 'pyobjc-framework-Cinematic' because it is not supported on the current platform Skipping 'pyobjc-framework-Symbols' because it is not supported on the current platform Skipping 'pyobjc-framework-SensitiveContentAnalysis' because it is not supported on the current platform Skipping 'pyobjc-framework-PubSub' because it is not supported on the current platform

But I can install them manually with pip3 install!

ronaldoussoren commented 1 year ago

I don't know why the example doesn't work for you, but it works for me.

What I did:

Cinematic, Symbols and SensitiveContentAnalisys are bindings for framework introduced in macOS 14. The PubSub package is a binding for a framework that was removed in macOS 10.15. All of them will by default only be installed on systems that have those frameworks, but it is possible to install the binary wheels on other macOS versions as well (primarily to support code that optionally uses those frameworks).