Homebrew + Python on mac os x 10.8:致命的Python错误:PyThreadState_Get:没有当前线程导入mapnik

时间:2013-03-28 09:23:58

标签: python module homebrew mapnik

我的mac上有2个pythons(10.8.3):默认版本,以及自制软件的2.7版本。

到目前为止,我可以安装模块并将其与我的brew python一起使用。我用brew install mapnik(mapnik-2.1.0)安装了mapnik并且编译正确。但是,如果我打开python并输入import mapnik,则会出现以下错误并退出python:

>>> import mapnik
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

Mac os x还显示错误窗口,其中包含以下内容:

Process:         Python [60666]
Path:            /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:      Python
Version:         2.7.3 (2.7.3)
Code Type:       X86-64 (Native)
Parent Process:  bash [60454]
User ID:         501

Date/Time:       2013-03-28 10:21:08.535 +0100
OS Version:      Mac OS X 10.8.3 (12D78)
Report Version:  10

Interval Since Last Report:          128837 sec
Crashes Since Last Report:           5
Per-App Crashes Since Last Report:   4
Anonymous UUID:                      567121E6-7BAC-335F-E3B0-DD24D1F9E6BA

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff94500d46 __kill + 10
1   libsystem_c.dylib               0x00007fff92afddf0 abort + 177
2   org.python.python               0x0000000105a77eaa Py_FatalError + 49
3   org.python.python               0x0000000105a76370 PyThreadState_Get + 28
4   org.python.python               0x0000000105a71f16 Py_InitModule4_64 + 58
5   libboost_python-mt.dylib        0x0000000104153288 boost::python::detail::init_module(char const*, void (*)()) + 40
6   org.python.python               0x00000001029fa716 _PyImport_LoadDynamicModule + 150
7   org.python.python               0x00000001029fa428 import_submodule + 296
8   org.python.python               0x00000001029f9ff1 load_next + 268
9   org.python.python               0x00000001029f80fb PyImport_ImportModuleLevel + 794
10  org.python.python               0x00000001029de9d3 builtin___import__ + 132
11  org.python.python               0x000000010296e335 PyObject_Call + 101
12  org.python.python               0x00000001029e8e10 PyEval_CallObjectWithKeywords + 93
13  org.python.python               0x00000001029e61b6 PyEval_EvalFrameEx + 11727
14  org.python.python               0x00000001029e32bd PyEval_EvalCodeEx + 1638
15  org.python.python               0x00000001029e2c51 PyEval_EvalCode + 54
16  org.python.python               0x00000001029f6e58 PyImport_ExecCodeModuleEx + 247
17  org.python.python               0x00000001029f99bf load_source_module + 1053
18  org.python.python               0x00000001029f9c7e load_package + 334
19  org.python.python               0x00000001029fa428 import_submodule + 296
20  org.python.python               0x00000001029f9ff1 load_next + 268
21  org.python.python               0x00000001029f80fb PyImport_ImportModuleLevel + 794
22  org.python.python               0x00000001029de9d3 builtin___import__ + 132
23  org.python.python               0x000000010296e335 PyObject_Call + 101
24  org.python.python               0x00000001029e8e10 PyEval_CallObjectWithKeywords + 93
25  org.python.python               0x00000001029e61b6 PyEval_EvalFrameEx + 11727
26  org.python.python               0x00000001029e32bd PyEval_EvalCodeEx + 1638
27  org.python.python               0x00000001029e2c51 PyEval_EvalCode + 54
28  org.python.python               0x0000000102a01a2b run_mod + 53
29  org.python.python               0x0000000102a0184d PyRun_InteractiveOneFlags + 365
30  org.python.python               0x0000000102a01367 PyRun_InteractiveLoopFlags + 188
31  org.python.python               0x0000000102a01218 PyRun_AnyFileExFlags + 60
32  org.python.python               0x0000000102a120b2 Py_Main + 3210
33  libdyld.dylib                   0x00007fff966bf7e1 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff5d29c2b0  rcx: 0x00007fff5d29c298  rdx: 0x0000000000000000
  rdi: 0x000000000000ecfa  rsi: 0x0000000000000006  rbp: 0x00007fff5d29c2c0  rsp: 0x00007fff5d29c298
   r8: 0x00000000000003f5   r9: 0x00007fff5d29c270  r10: 0x00007fff94502342  r11: 0x0000000000000206
  r12: 0x00007fff5d29cb00  r13: 0x0000000102e9b656  r14: 0x00000000000003f5  r15: 0x0000000000000000
  rip: 0x00007fff94500d46  rfl: 0x0000000000000206  cr2: 0x00007fff7bff7ff0
Logical CPU: 0

Binary Images:
       0x102961000 -        0x102961fff +org.python.python (2.7.3 - 2.7.3) <62DA7BCA-2A0C-3753-A043-7459827F56D1> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
       0x102964000 -        0x102a6cfff +org.python.python (2.7.3, [c] 2004-2012 Python Software Foundation. - 2.7.3) <81E6FB4A-287C-37C3-A26D-D045B604933F> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python
       0x102c4c000 -        0x102c4efff +readline.so (0) <C4F1219C-CDFD-37D2-A762-22974D3F2918> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
       0x102c54000 -        0x102c77fff +libreadline.6.2.dylib (6.2) <2131C2A4-E75D-3680-9C8D-E42D78A5E1B9> /usr/local/opt/readline/lib/libreadline.6.2.dylib
       0x102cfc000 -        0x102d01fff +itertools.so (0) <F857A819-40A9-3F72-A0B1-3E97BA5F3DAA> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/itertools.so
       0x102d0a000 -        0x102f2cfff +_mapnik.so (0) <433DAD47-AB4D-37C5-A0EA-FE1134B63D3D> /usr/local/lib/python2.7/site-packages/mapnik/_mapnik.so
       0x103603000 -        0x103978ff7 +libmapnik.dylib (0) <0E898678-9D86-35B4-A772-0248924F5BF3> /usr/local/Cellar/mapnik/2.1.0/lib/libmapnik.dylib
       0x104138000 -        0x104170ff7 +libboost_python-mt.dylib (0) <9B5DD680-BEC9-3988-9F55-F59DA38CC175> /usr/local/lib/libboost_python-mt.dylib
       0x1041b3000 -        0x1041c2ff7 +libboost_thread-mt.dylib (0) <24432300-9373-30B6-89F6-857CBEF9C105> /usr/local/lib/libboost_thread-mt.dylib
       0x1041de000 -        0x10424dff7 +libfreetype.6.dylib (0) <490EDE42-5B78-34BA-85E7-D0547BE778E1> /usr/local/lib/libfreetype.6.dylib
       0x104262000 -        0x104268fff +libltdl.7.dylib (0) <E437E59F-FC2E-3837-BDF8-301BEF13C7D6> /usr/local/lib/libltdl.7.dylib
       0x10426c000 -        0x10428bff7 +libpng15.15.dylib (0) <52907DBF-A04C-325D-9E77-DF56A771026F> /usr/local/lib/libpng15.15.dylib
       0x104293000 -        0x1042e6fff +libtiff.5.dylib (0) <AE85D7B1-F4E5-3B27-832D-5756EFCDE912> /usr/local/lib/libtiff.5.dylib
       0x1042f2000 -        0x104326fff +libproj.0.dylib (0) <C799D9A7-0DDA-334D-9AEA-13A4AE7A67A2> /usr/local/lib/libproj.0.dylib
       0x104333000 -        0x104441ff7 +libicuuc.50.1.dylib (0) <5FDBBF25-EEA6-3649-9ED6-B18CE89CE510> /usr/local/opt/icu4c/lib/libicuuc.50.1.dylib
       0x1044a3000 -        0x1044b2fff +libboost_filesystem-mt.dylib (0) <B2C03485-5FA6-3744-BC99-DB4E87DA4D87> /usr/local/lib/libboost_filesystem-mt.dylib
       0x1044c3000 -        0x1044c5ff7 +libboost_system-mt.dylib (0) <FE5E6E11-C7FB-3895-9976-526D22997EDC> /usr/local/lib/libboost_system-mt.dylib
       0x1044ca000 -        0x104578fff +libboost_regex-mt.dylib (0) <BC1D7F46-F6AB-3964-B344-E692EFC5D3B7> /usr/local/lib/libboost_regex-mt.dylib
       0x10461c000 -        0x10464bff7 +libjpeg.8.dylib (0) <9EC07360-CF18-3529-AE54-E60DBF1313DC> /usr/local/lib/libjpeg.8.dylib
       0x104652000 -        0x105a24fff +libicudata.50.dylib (0) <B74D5789-7082-3084-9BF0-9A3AE6F2B046> /usr/local/opt/icu4c/lib/libicudata.50.dylib
       0x105a26000 -        0x105b33fff  org.python.python (2.7.2 - 2.7.2) <E7F3EED1-E55D-32AF-9649-77C814693F6A> /System/Library/Frameworks/Python.framework/Versions/2.7/Python
    0x7fff62561000 -     0x7fff6259593f  dyld (210.2.3) <36CAA36E-72BC-3E48-96D9-B96A2DF77730> /usr/lib/dyld
    0x7fff8ae57000 -     0x7fff8ae7cff7  libc++abi.dylib (26) <D86169F3-9F31-377A-9AF3-DB17142052E4> /usr/lib/libc++abi.dylib
    0x7fff8c50f000 -     0x7fff8c510ff7  libsystem_sandbox.dylib (220.2) <6838A6FD-8626-3356-BB4F-BB4787216207> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff8c511000 -     0x7fff8c523ff7  libz.1.dylib (43) <2A1551E8-A272-3DE5-B692-955974FE1416> /usr/lib/libz.1.dylib
    0x7fff8d337000 -     0x7fff8d342fff  libsystem_notify.dylib (98.5) <C49275CC-835A-3207-AFBA-8C01374927B6> /usr/lib/system/libsystem_notify.dylib
    0x7fff8d9e6000 -     0x7fff8d9ebfff  libcompiler_rt.dylib (30) <08F8731D-5961-39F1-AD00-4590321D24A9> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8dd72000 -     0x7fff8dd73fff  libDiagnosticMessagesClient.dylib (8) <8548E0DC-0D2F-30B6-B045-FE8A038E76D8> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff902d7000 -     0x7fff90326ff7  libcorecrypto.dylib (106.2) <CE0C29A3-C420-339B-ADAA-52F4683233CC> /usr/lib/system/libcorecrypto.dylib
    0x7fff9064f000 -     0x7fff90650fff  libsystem_blocks.dylib (59) <D92DCBC3-541C-37BD-AADE-ACC75A0C59C8> /usr/lib/system/libsystem_blocks.dylib
    0x7fff90a75000 -     0x7fff90a7dff7  libsystem_dnssd.dylib (379.37) <616FC901-151E-38BF-B2C4-24A351C5FAAD> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff914fd000 -     0x7fff9150afff  libbz2.1.0.dylib (29) <CE9785E8-B535-3504-B392-82F0064D9AF2> /usr/lib/libbz2.1.0.dylib
    0x7fff92899000 -     0x7fff928a7fff  libcommonCrypto.dylib (60027) <BAAFE0C9-BB86-3CA7-88C0-E3CBA98DA06F> /usr/lib/system/libcommonCrypto.dylib
    0x7fff92aa4000 -     0x7fff92b70ff7  libsystem_c.dylib (825.26) <4C9EB006-FE1F-3F8F-8074-DFD94CF2CE7B> /usr/lib/system/libsystem_c.dylib
    0x7fff92bba000 -     0x7fff92bc0ff7  libunwind.dylib (35.1) <21703D36-2DAB-3D8B-8442-EAAB23C060D3> /usr/lib/system/libunwind.dylib
    0x7fff92ed3000 -     0x7fff92f3cfff  libstdc++.6.dylib (56) <EAA2B53E-EADE-39CF-A0EF-FB9D4940672A> /usr/lib/libstdc++.6.dylib
    0x7fff93019000 -     0x7fff93065ff7  libauto.dylib (185.1) <73CDC482-16E3-3FC7-9BB4-FBA2DA44DBC2> /usr/lib/libauto.dylib
    0x7fff930cf000 -     0x7fff930d5fff  libmacho.dylib (829) <BF332AD9-E89F-387E-92A4-6E1AB74BD4D9> /usr/lib/system/libmacho.dylib
    0x7fff93177000 -     0x7fff93199ff7  libxpc.dylib (140.42) <BBE558BD-5E55-35E4-89ED-1AA6B056D05A> /usr/lib/system/libxpc.dylib
    0x7fff931f6000 -     0x7fff931f7ff7  libremovefile.dylib (23.2) <6763BC8E-18B8-3AD9-8FFA-B43713A7264F> /usr/lib/system/libremovefile.dylib
    0x7fff931f8000 -     0x7fff93260ff7  libc++.1.dylib (65.1) <20E31B90-19B9-3C2A-A9EB-474E08F9FE05> /usr/lib/libc++.1.dylib
    0x7fff9345d000 -     0x7fff9365dfff  libicucore.A.dylib (491.11.2) <FD6282D8-DF3F-3842-8C2E-CF478D2B9669> /usr/lib/libicucore.A.dylib
    0x7fff9365e000 -     0x7fff9365efff  libkeymgr.dylib (25) <CC9E3394-BE16-397F-926B-E579B60EE429> /usr/lib/system/libkeymgr.dylib
    0x7fff936d4000 -     0x7fff936dcfff  liblaunch.dylib (442.26.2) <2F71CAF8-6524-329E-AC56-C506658B4C0C> /usr/lib/system/liblaunch.dylib
    0x7fff9424d000 -     0x7fff9427bff7  libsystem_m.dylib (3022.6) <B434BE5C-25AB-3EBD-BAA7-5304B34E3441> /usr/lib/system/libsystem_m.dylib
    0x7fff94284000 -     0x7fff94286fff  libquarantine.dylib (52) <4BE2E642-A14F-340A-B482-5BD2AEFD9C24> /usr/lib/system/libquarantine.dylib
    0x7fff94381000 -     0x7fff94382ff7  libdnsinfo.dylib (453.19) <14202FFB-C3CA-3FCC-94B0-14611BF8692D> /usr/lib/system/libdnsinfo.dylib
    0x7fff944ef000 -     0x7fff9450aff7  libsystem_kernel.dylib (2050.22.13) <5A961E2A-CFB8-362B-BC43-122704AEB047> /usr/lib/system/libsystem_kernel.dylib
    0x7fff94579000 -     0x7fff94587ff7  libsystem_network.dylib (77.10) <0D99F24E-56FE-380F-B81B-4A4C630EE587> /usr/lib/system/libsystem_network.dylib
    0x7fff94821000 -     0x7fff9493992f  libobjc.A.dylib (532.2) <90D31928-F48D-3E37-874F-220A51FD9E37> /usr/lib/libobjc.A.dylib
    0x7fff9493a000 -     0x7fff9494fff7  libdispatch.dylib (228.23) <D26996BF-FC57-39EB-8829-F63585561E09> /usr/lib/system/libdispatch.dylib
    0x7fff95c25000 -     0x7fff95d22ff7  libxml2.2.dylib (22.3) <47B09CB2-C636-3024-8B55-6040F7829B4C> /usr/lib/libxml2.2.dylib
    0x7fff96350000 -     0x7fff96351ff7  libSystem.B.dylib (169.3) <9089D72D-E714-31E1-80C8-698A8E8B05AD> /usr/lib/libSystem.B.dylib
    0x7fff96397000 -     0x7fff9639cfff  libcache.dylib (57) <65187C6E-3FBF-3EB8-A1AA-389445E2984D> /usr/lib/system/libcache.dylib
    0x7fff96646000 -     0x7fff9664dfff  libcopyfile.dylib (89) <876573D0-E907-3566-A108-577EAD1B6182> /usr/lib/system/libcopyfile.dylib
    0x7fff966bd000 -     0x7fff966c0ff7  libdyld.dylib (210.2.3) <F59367C9-C110-382B-A695-9035A6DD387E> /usr/lib/system/libdyld.dylib
    0x7fff96961000 -     0x7fff96963ff7  libunc.dylib (25) <92805328-CD36-34FF-9436-571AB0485072> /usr/lib/system/libunc.dylib
    0x7fff974ba000 -     0x7fff974f0fff  libsystem_info.dylib (406.17) <4FFCA242-7F04-365F-87A6-D4EFB89503C1> /usr/lib/system/libsystem_info.dylib
    0x7fff97850000 -     0x7fff97888fff  libncurses.5.4.dylib (37.3) <68D5B5F5-8252-3F1E-AFF1-C6AFE145DBC1> /usr/lib/libncurses.5.4.dylib
    0x7fff978d3000 -     0x7fff97abdff7  com.apple.CoreFoundation (6.8 - 744.18) <A60C3C9B-3764-3291-844C-C487ACF77C2C> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 18730
    thread_create: 2
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=109.5M resident=53.3M(49%) swapped_out_or_unallocated=56.2M(51%)
Writable regions: Total=20.6M written=2644K(13%) resident=3256K(15%) swapped_out=0K(0%) unallocated=17.5M(85%)

REGION TYPE                      VIRTUAL
===========                      =======
MALLOC                             11.8M
MALLOC guard page                    32K
STACK GUARD                        56.0M
Stack                              8192K
__DATA                             2356K
__LINKEDIT                         68.3M
__TEXT                             41.2M
__UNICODE                           544K
shared memory                        12K
===========                      =======
TOTAL                             188.2M

Model: MacBookPro8,2, BootROM MBP81.0047.B27, 4 processors, Intel Core i7, 2 GHz, 8 GB, SMC 1.69f4
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 512 MB
Graphics: AMD Radeon HD 6490M, AMD Radeon HD 6490M, PCIe, 256 MB
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353237334348302D4348392020
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x80CE, 0x4D34373142353237334348302D4348392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 (5.106.98.100.16)
Bluetooth: Version 4.1.3f3 11349, 2 service, 11 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: ST9500420AS, 500.11 GB
Serial ATA Device: MATSHITADVD-R   UJ-898
USB Device: FaceTime HD Camera (Built-in), apple_vendor_id, 0x8509, 0xfa200000 / 3
USB Device: hub_device, 0x0424  (SMSC), 0x2513, 0xfa100000 / 2
USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id, 0x0246, 0xfa120000 / 5
USB Device: BRCM2070 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0xfa110000 / 4
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x821a, 0xfa113000 / 8
USB Device: hub_device, 0x0424  (SMSC), 0x2513, 0xfd100000 / 2
USB Device: IR Receiver, apple_vendor_id, 0x8242, 0xfd110000 / 3

链接我的蟒蛇有什么问题吗?我该怎么解决?谢谢!

4 个答案:

答案 0 :(得分:12)

看起来你正在运行自制的python,但是升级python或mapnik的python绑定最终链接到了apple提供的系统python。如果完全清理并重新安装boost和Mapnik不能解决这个问题,那么我建议在freenode上停止#mapnik irc以获得帮助调试。通常要解决此问题,您需要在otool -L和/或boost_python.dylib上调用site_packages/mapnik/_mapnik.so,以查看最终与系统python的链接。然后,您可以使用install_name_tool进行修复。

答案 1 :(得分:4)

我在python27-apple和python27(由Macport安装)之间遇到了同样的问题。我尝试了这些步骤,它对我有用。

根据@Evert对不同python使用的不同库的评论,我试图将python27-apple恢复为“活跃”。

sudo port select --list python

对于我的电脑,它显示:

Available versions for python:
none
python25-apple
python26
python26-apple
python27 (active)
python27-apple

其中python27(由Macport提供)当前处于活动状态。然后,

sudo port select python python27-apple

使python27-apple处于活动状态,因为之前调用了默认的lib。要仔细检查,

sudo port select --list python

现在显示:

Available versions for python:
none
python25-apple
python26
python26-apple
python27
python27-apple (active)

当我运行脚本时,python崩溃了。

答案 2 :(得分:2)

我在使用Fatal Python error: PyThreadState_Get: no current thread Abort trap: 6时遇到了类似的问题。虽然它不完全相同,但它可以作为参考。我的崩溃也是otool -L <lib>。运行dylib,建议系统python的python-config --ldflags链接。 尝试解决方案:

  1. LDFLAGS += -lm -lbz2 -lz -llzma -lsnappy -lmuparser -lpython
  2. 将输出复制到相应的MakeFile。例如,将LDFLAGS += -lm -lbz2 -lz -llzma -lsnappy -lmuparser -L/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -ldl -framework CoreFoundation更改为make clean
  3. otool -L <lib>,然后重新制作。
  4. 现在dylib没问题,再也没有错误了。

    或者......

    ...当您使用dylib查找错误链接的python install_name_tool时,您可以使用 install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib <lib> 更改符号,如:

    SqlDataAdapter sdaTemp = new SqlDataAdapter();
    DataTable dtTemp = new DataTable();
    MyGlobalVariables.con.Open();
    sdaTemp = new SqlDataAdapter("Select * from Increment where ecode=(select MAX(ecode) from Increment) and UserID='"+MyGlobalVariables.MyUid+"'", MyGlobalVariables.con);
    MyGlobalVariables.con.Close();
    sdaTemp.Fill(dtTemp);
    MyGlobalVariables.dtEmp.Merge(dtTemp);
    MyGlobalVariables.dtEmp.AcceptChanges();
    MyGlobalVariables.bsEmp.MoveLast();
    

答案 3 :(得分:2)

你可以像这样使用自制的python:

/usr/bin/python2.7 yourscript.py