运行PyInstaller二进制文件“致命Python错误:PyThreadState\u Get:无当前线程”时出错

运行PyInstaller二进制文件“致命Python错误:PyThreadState\u Get:无当前线程”时出错,python,python-2.7,pyinstaller,python-bindings,Python,Python 2.7,Pyinstaller,Python Bindings,我是python新手,对pyinstaller有疑问 我所拥有的: 使用PosithPython导入C++中动态库的Python脚本 如果我使用python运行这个脚本,一切都很好 python main.py startup 如果我使用pyinstaller创建二进制文件,然后尝试运行它,我会得到以下结果 dhcp80-241:bin gburanov$ ./my_binary startup Fatal Python error: PyThreadState_Get: no current

我是python新手,对pyinstaller有疑问

我所拥有的:

使用PosithPython导入C++中动态库的Python脚本 如果我使用python运行这个脚本,一切都很好

python main.py startup
如果我使用pyinstaller创建二进制文件,然后尝试运行它,我会得到以下结果

dhcp80-241:bin gburanov$ ./my_binary startup
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8b997d46 __kill + 10
1   libsystem_c.dylib               0x00007fff84074f83 abort + 177
2   org.python.python               0x0000000108fe6eaa Py_FatalError + 49
3   org.python.python               0x0000000108fe5370 PyThreadState_Get + 28
4   org.python.python               0x0000000108fe0f16 Py_InitModule4_64 + 58
5   idver_wrapper.so                0x0000000108f3cfb4 boost::python::detail::init_module(char const*, void (*)()) + 36
6   idver_wrapper.so                0x0000000108f29eeb initidver_wrapper + 27
7   Python                          0x0000000108babe0d _PyImport_LoadDynamicModule + 183
8   Python                          0x0000000108ba66a6 0x108b66000 + 263846
9   Python                          0x0000000108b7f5a9 PyEval_EvalFrameEx + 9244
10  Python                          0x0000000108b7d147 PyEval_EvalCodeEx + 1934
11  Python                          0x0000000108bb6d7a 0x108b66000 + 331130
     dhcp80-241:src gburanov$ otool -L ./idver_wrapper.so
     ./idver_wrapper.so:
      /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
      /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
崩溃的回溯跟踪如下

dhcp80-241:bin gburanov$ ./my_binary startup
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8b997d46 __kill + 10
1   libsystem_c.dylib               0x00007fff84074f83 abort + 177
2   org.python.python               0x0000000108fe6eaa Py_FatalError + 49
3   org.python.python               0x0000000108fe5370 PyThreadState_Get + 28
4   org.python.python               0x0000000108fe0f16 Py_InitModule4_64 + 58
5   idver_wrapper.so                0x0000000108f3cfb4 boost::python::detail::init_module(char const*, void (*)()) + 36
6   idver_wrapper.so                0x0000000108f29eeb initidver_wrapper + 27
7   Python                          0x0000000108babe0d _PyImport_LoadDynamicModule + 183
8   Python                          0x0000000108ba66a6 0x108b66000 + 263846
9   Python                          0x0000000108b7f5a9 PyEval_EvalFrameEx + 9244
10  Python                          0x0000000108b7d147 PyEval_EvalCodeEx + 1934
11  Python                          0x0000000108bb6d7a 0x108b66000 + 331130
     dhcp80-241:src gburanov$ otool -L ./idver_wrapper.so
     ./idver_wrapper.so:
      /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
      /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
我已经读到,问题可能是动态库链接到一个版本的python,pyinstaller链接到这里提到的另一个版本的python,但我检查了以下内容

dhcp80-241:bin gburanov$ ./my_binary startup
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8b997d46 __kill + 10
1   libsystem_c.dylib               0x00007fff84074f83 abort + 177
2   org.python.python               0x0000000108fe6eaa Py_FatalError + 49
3   org.python.python               0x0000000108fe5370 PyThreadState_Get + 28
4   org.python.python               0x0000000108fe0f16 Py_InitModule4_64 + 58
5   idver_wrapper.so                0x0000000108f3cfb4 boost::python::detail::init_module(char const*, void (*)()) + 36
6   idver_wrapper.so                0x0000000108f29eeb initidver_wrapper + 27
7   Python                          0x0000000108babe0d _PyImport_LoadDynamicModule + 183
8   Python                          0x0000000108ba66a6 0x108b66000 + 263846
9   Python                          0x0000000108b7f5a9 PyEval_EvalFrameEx + 9244
10  Python                          0x0000000108b7d147 PyEval_EvalCodeEx + 1934
11  Python                          0x0000000108bb6d7a 0x108b66000 + 331130
     dhcp80-241:src gburanov$ otool -L ./idver_wrapper.so
     ./idver_wrapper.so:
      /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
      /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
和pyinstaller日志

    151 INFO: wrote /Users/gburanov/repo/..../build/my_binary.spec
    177 WARNING: You are running 64-bit Python: created binaries will only work on Mac OS X 10.6+.
    If you need 10.4-10.5 compatibility, run Python as a 32-bit binary with this command:

     VERSIONER_PYTHON_PREFER_32_BIT=yes arch -i386 /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
因此,我的结论是pyinstaller和动态库python版本是相同的

那么,问题的根源是什么

稍后添加: 我仔细查看了坠机报告,注意到我还有两条二进制蟒蛇

Binary Images:
   0x108b0c000 -        0x108b28fff +sauth_binary (???) <9713FFC1-8C05-32D2-9F32-2D66A090EB52> /Users/USER/Downloads/sauth_binary
   0x108b66000 -        0x108c73fff +Python (60.4) <E7F3EED1-E55D-32AF-9649-77C814693F6A> /var/folders/*/Python
   0x108d89000 -        0x108d8cfff +_struct.so (60.4) <FF637943-8866-37F5-8B48-B97002F502A3> /var/folders/*/_struct.so
   0x108d92000 -        0x108d94fff +zlib.so (60.4) <9F2F691B-1510-335A-B9FE-6600523D90FB> /var/folders/*/zlib.so
   0x108eaa000 -        0x108eadfff +_collections.so (60.4) <02413565-C29E-3C7A-8E01-8C9C19642F15> /var/folders/*/_collections.so
   0x108eb3000 -        0x108eb6fff +operator.so (60.4) <FD5EC6F3-D0F9-358F-BF08-DC4B4F2109CB> /var/folders/*/operator.so
   0x108ebc000 -        0x108ec2fff +itertools.so (60.4) <36330819-32C7-3183-B213-2E1142050B3B> /var/folders/*/itertools.so
   0x108ecb000 -        0x108ecbfff +_bisect.so (60.4) <EE97CCA4-3D48-3CEC-B163-37E3AC0DCDA1> /var/folders/*/_bisect.so
   0x108ecf000 -        0x108ed0fff +_heapq.so (60.4) <7B91BA4D-5485-31BA-9FF9-789C6F3D0820> /var/folders/*/_heapq.so
   0x108f15000 -        0x108f18fff +strop.so (60.4) <282D8F1C-D709-339B-86E2-CE318F0E28E6> /var/folders/*/strop.so
   0x108f1e000 -        0x108f1ffff +_functools.so (60.4) <4DF8234E-F5DF-315B-A1CA-7C8C5C203901> /var/folders/*/_functools.so
   0x108f23000 -        0x108f24fff +_locale.so (60.4) <F8B95D0E-DAE2-359E-8B79-E3C8BE477D2D> /var/folders/*/_locale.so
   0x108f28000 -        0x108f60ff7 +idver_wrapper.so (0) <9EAC31C1-AE3B-33BA-B104-B80A7CD0FC14> /var/folders/*/idver_wrapper.so
   0x108f95000 -        0x1090a2fff  org.python.python (2.7.2 - 2.7.2) <E7F3EED1-E55D-32AF-9649-77C814693F6A> /System/Library/Frameworks/Python.framework/Versions/2.7/Python
但是第二个在temp目录/var/folders中,二进制文件等于/System/Library/Frameworks/Python.framework/Versions/2.7/Python