Re: PyObjC - Apple sample code

Ben Byram-Wigfield <[email protected]> Thu, 27 Apr 2017 09:17:09 +0100
Newsgroups gmane.comp.python.apple
Message-ID <[email protected]>
I tried the repository browser there, and the version of parse_page_contents.py still doesn’t work for me. I’m using the latest downloaded versions of python 2.7 and PyObjC. I also tried using the default OS X versions.
The errors are in the attached file.

Many thanks


Ben


> On 27 Apr 2017, at 08:53, Ronald Oussoren <[email protected]> wrote:
> 
>> 
>> On 22 Apr 2017, at 10:45, Ben Byram-Wigfield <[email protected]> wrote:
>> 
>> I’ve been looking at Apple’s Open Source website, where there is lots of python sample code. But the examples I’ve tried don’t work. They all flag syntax errors (usually about type conversion), or occasionally make the python process crash!
>> 
>> Particularly, I’m looking at a script to parse the contents of a PDF file. There are a few slightly different versions (and I don’t understand all the different folders — pyobj 14, 26, 47, 49???)
>> 
>> https://opensource.apple.com/source/pyobjc/pyobjc-49/pyobjc/pyobjc-framework-Quartz-2.5.1/Examples/Programming%20with%20Quartz/ParsePageContents/parse_page_contents.py
>> 
>> https://opensource.apple.com/source/pyobjc/pyobjc-14.1.1/pyobjc/stable/pyobjc-framework-Quartz/Examples/Programming%20with%20Quartz/ParsePageContents/parse_page_contents.py
>> 
>> But none of them work. I’ve tried them on PyObjc 2.5.1 and 3.2.1, which gives different syntax errors. (Question 2, why does OS X ship with only 2.5.1?)
>> 
>> I’ve scoured the internet for better examples of python-quartz-pdf_parsing, but not found anything. The Apple Dev Forums suggested that the code wasn’t maintained by Apple, but by PyObjC.
> 
> See http://pyobjc.sf.net/, which contains all current examples and those should work with the current release of PyObjC and python 2.7 and 3.x.
> 
> Ronald

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG
python_errors.txt (text/plain, 1.9 KB)
ERRORS USING LATEST DOWNLOADED PYTHON 2.7.14 AND PYOBJC 3.2.1.


Traceback (most recent call last):
  File "/Users/Ben/Documents/Python Scripts/parse_page_contents.py.py", line 8, in <module>
    import objc
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyobjc_core-3.2.1-py2.7-macosx-10.6-intel.egg/objc/__init__.py", line 32, in <module>
    from objc._bridgesupport import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyobjc_core-3.2.1-py2.7-macosx-10.6-intel.egg/objc/_bridgesupport.py", line 13, in <module>
    import pkg_resources
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 22, in <module>
    import io
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so


-----------------------------------------------------------
ERRORS USING BUNDLED OS X  PYTHON 2.7.10 AND PYOBJC 2.5.1.

  File "/Users/Ben/Documents/Python Scripts/parse_page_contents.py", line 276, in <module>
    sys.exit(main())
  File "/Users/Ben/Documents/Python Scripts/parse_page_contents.py", line 271, in main
    dumpPageStreams(inURL, sys.stdout)
  File "/Users/Ben/Documents/Python Scripts/parse_page_contents.py", line 189, in dumpPageStreams
    table = createMyOperatorTable();
  File "/Users/Ben/Documents/Python Scripts/parse_page_contents.py", line 177, in createMyOperatorTable
    Quartz.CGPDFOperatorTableSetCallback(myTable, b"Do", myOperator_Do)
ValueError: depythonifying 'pointer', got 'str'