Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing pyobjc imports in PyDev in Eclipse on Mac OS X
    primarykey
    data
    text
    <p>I've installed and configured PyDev version 1.6.5.2011020317 inside Eclipse, running on Mac OS X 10.6.6:</p> <blockquote> <p>Version: Helios Service Release 1 Build id: 20100917-0705</p> </blockquote> <p>I used 'Auto Config' to set up my Python interpreter: it correctly found <code>/usr/bin/python</code> (which is Python version 2.6.1) and added various system folders to the <code>PYTHONPATH</code>, including <code>/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC</code>. Now <em>that path</em> is the correct path to the <code>Foundation</code> module in OS X, as evinced by the command-line interpreter:</p> <pre><code>$ python Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import Foundation &gt;&gt;&gt; Foundation.__path__ ['/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/Foundation'] </code></pre> <p>So why does PyDev complain about "Undefined variable from import: NSDictionary" on this class:</p> <pre><code>import Foundation class MyClass(object): def __init__(self, projectPath): ''' Constructor ''' self.projectDict = Foundation.NSDictionary.dictionaryWithContentsOfFile_(projectPath) </code></pre> <p>when I can use that class without any problem from the command-line interpreter?</p> <p><em>Update</em>: OK, I found out <em>why</em> it complains, which is that the <code>Foundation</code> module is using ScriptingBridge to dynamically generate the classes - presumably pydev isn't actually importing the module to see what classes are inside, it's just looking for <code>.py[c]</code> files. So let my question not be "why does this happen", but "what do I do to fix it"?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload