Opened 8 years ago

Closed 4 years ago

#26186 closed defect (wontfix)

python25: No module named _ctypes

Reported by: joe.paxton@… Owned by: jyrkiwahlstedt
Priority: Normal Milestone:
Component: ports Version: 1.9.1
Keywords: Cc: jameskyle@…, ryandesign (Ryan Schmidt), luca@…
Port: python25


Mac OS X 10.6.4 Xcode 3.2.2

When attempting to get a list of installed modules (help('modules')) in python25, I'm getting the following error message: NameError: name 'ctypes' is not defined

The problem does not appear to be an upstream issue, as the version of python 2.5 that comes pre-installed in Snow Leopard doesn't

The full traceback follows:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 346, in __call__
    return*args, **kwds)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 1646, in __call__
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 1683, in help
    elif request == 'modules': self.listmodules()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 1804, in listmodules
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 1855, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 125, in walk_packages
    for item in walk_packages(path, name+'.', onerror):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/", line 110, in walk_packages
  File "/opt/local/lib/python2.5/site-packages/PsychoPy-1.62.00-py2.5.egg/psychopy/ext/", line 18, in <module>
    from darwin import *
  File "/opt/local/lib/python2.5/site-packages/PsychoPy-1.62.00-py2.5.egg/psychopy/ext/", line 16, in <module>
    kCGLCPSwapInterval= ctypes.c_int(222)
NameError: name 'ctypes' is not defined

Change History (8)

comment:1 Changed 8 years ago by joe.paxton@…

Sorry for the double submission. Please ignore the first one (#26185).

comment:2 Changed 8 years ago by joe.paxton@…

And please let me know if this is better categorized as a bug with PsychoPy, and I'll submit a ticket to that package's maintainer.

comment:3 Changed 8 years ago by jmroot (Joshua Root)

Cc: jwa@… jameskyle@… added; joe.paxton@… removed
Keywords: python25 ctypes removed
Port: py25-psychopy added; @2.5.5 removed
Summary: python25-2.5.5 NameError: name 'ctypes' is not definedpython25 @2.5.5 + PsychoPy: NameError: name 'ctypes' is not defined

Please remember to cc the maintainer, and note that you do not need to be in cc when you are the reporter.

comment:4 Changed 8 years ago by joe.paxton@…

The traceback I originally submitted was for the wrong version of psychopy. Here is the correct traceback:

Traceback (most recent call last):
  File "./", line 4, in <module>
    from psychopy import visual, core, event 
  File "/opt/local/lib/python2.5/site-packages/psychopy/", line 8, in <module>
    from psychopy import core, ext, log, preferences, monitors
  File "/opt/local/lib/python2.5/site-packages/psychopy/", line 8, in <module>
    from ext import rush
  File "/opt/local/lib/python2.5/site-packages/psychopy/ext/", line 11, in <module>
    from darwin import *
  File "/opt/local/lib/python2.5/site-packages/psychopy/ext/", line 5, in <module>
    import sys, ctypes, ctypes.util, time
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/", line 10, in <module>
    from _ctypes import Union, Structure, Array
ImportError: No module named _ctypes

However, given that I'm getting the same error with both versions of psychopy (both the Macports version and the most recent version installed thru easy_install), perhaps this is actually an upstream problem? If so, feel free to close this ticket, and I'll submit the bug to the psychopy devs.

comment:5 Changed 7 years ago by ryandesign (Ryan Schmidt)

Cc: ryandesign@… added; jwa@… removed
Owner: changed from macports-tickets@… to jwa@…
Port: py25-psychopy removed
Summary: python25 @2.5.5 + PsychoPy: NameError: name 'ctypes' is not definedpython25: No module named _ctypes

Indeed, python25 does not install the ctypes module, though it should, and though other ports rightly expect it to. python25 installs without error, but if you look in the verbose build output, it says:

*** WARNING: renaming "_ctypes" since importing it failed: dlopen(build/lib.macosx-10.6-i386-2.5/, 2): Symbol not found: _ffi_call
  Referenced from: /opt/local/var/macports/build/_Users_rschmidt_macports_dports_lang_python25/work/Python-2.5.5/build/lib.macosx-10.6-i386-2.5/
  Expected in: flat namespace
 in /opt/local/var/macports/build/_Users_rschmidt_macports_dports_lang_python25/work/Python-2.5.5/build/lib.macosx-10.6-i386-2.5/

comment:6 Changed 7 years ago by luca@…

Cc: luca@… added

Cc Me!

comment:7 Changed 7 years ago by jmroot (Joshua Root)

It appears that the bundled libffi, like many other things in python < 2.6, doesn't work right on 64-bit OS X. Fixing this would likely require considerable effort and involve a lot of the changes that went into python 2.6. Unless a patch turns up, I think the maintainer should feel free to resolve this as wontfix.

comment:8 Changed 4 years ago by jyrkiwahlstedt

Resolution: wontfix
Status: newclosed

I’ll close this, current Python 2.x being 2.7, it should be used, if 2 series Python must be used

Note: See TracTickets for help on using tickets.