<i id='HMksv'><tr id='HMksv'><dt id='HMksv'><q id='HMksv'><span id='HMksv'><b id='HMksv'><form id='HMksv'><ins id='HMksv'></ins><ul id='HMksv'></ul><sub id='HMksv'></sub></form><legend id='HMksv'></legend><bdo id='HMksv'><pre id='HMksv'><center id='HMksv'></center></pre></bdo></b><th id='HMksv'></th></span></q></dt></tr></i><div id='HMksv'><tfoot id='HMksv'></tfoot><dl id='HMksv'><fieldset id='HMksv'></fieldset></dl></div>
      <tfoot id='HMksv'></tfoot>

      <small id='HMksv'></small><noframes id='HMksv'>

      • <bdo id='HMksv'></bdo><ul id='HMksv'></ul>

      1. <legend id='HMksv'><style id='HMksv'><dir id='HMksv'><q id='HMksv'></q></dir></style></legend>

        如何在 Windows 上调试 Python 的 C 扩展

        How to debug C extensions for Python on Windows(如何在 Windows 上调试 Python 的 C 扩展)
          <tbody id='mhCmX'></tbody>

      2. <tfoot id='mhCmX'></tfoot>

            <i id='mhCmX'><tr id='mhCmX'><dt id='mhCmX'><q id='mhCmX'><span id='mhCmX'><b id='mhCmX'><form id='mhCmX'><ins id='mhCmX'></ins><ul id='mhCmX'></ul><sub id='mhCmX'></sub></form><legend id='mhCmX'></legend><bdo id='mhCmX'><pre id='mhCmX'><center id='mhCmX'></center></pre></bdo></b><th id='mhCmX'></th></span></q></dt></tr></i><div id='mhCmX'><tfoot id='mhCmX'></tfoot><dl id='mhCmX'><fieldset id='mhCmX'></fieldset></dl></div>

            <small id='mhCmX'></small><noframes id='mhCmX'>

              • <legend id='mhCmX'><style id='mhCmX'><dir id='mhCmX'><q id='mhCmX'></q></dir></style></legend>
                • <bdo id='mhCmX'></bdo><ul id='mhCmX'></ul>
                  本文介绍了如何在 Windows 上调试 Python 的 C 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I have a problem with a segfault in pyodbc and would like to debug it in Windows XP x86. However, the information online seems primarily Linux-centric. What is the best way to go about this?

                  解决方案

                  So I was able to successfully resolve my issue by using Visual Studio 2008. I loosely followed the steps listed here -

                  http://www.velocityreviews.com/forums/t329214-debugging-python-extensions.html

                  And some tips on workarounds here -

                  Compiling python modules whith DEBUG defined on MSVC

                  Here is my version of the steps for anyone else who may encounter this problem.

                  1. In case you haven't already, be sure to setup the Python header and libs directories in VS

                    a. Go to Tools > Options > Projects and Solutions > VC++ Directories. Be sure to add your include and libs path to the Include and Library files' path, respectively. (e.g. C:Python27include, C:Python27libs)

                  2. Go to your Python include folder (once again, e.g. C:Python27include) and edit pyconfig.h. Comment out the line # define Py_DEBUG and save. Go to your libs folder (e.g. C:Python27libs) and make a copy of python27.lib. Name the copy python27_d.lib.

                  3. Create a new project. Choose Win32 Project and name it the module name (in my case pyodbc. Click Next then choose DLL for Application type and check Empty Project.

                  4. In the Solution Explorer, right-click on Header Files and choose Add > Existing Item. Select all of the header files that you need. Do the same for Source Files.

                  5. Go to Project > Properties, then under Configuration Properties -

                    a. General - ensure that you are using the correct Character Set. For me it was Use Multi-Byte Character Set. Python 3 probably needs Use Unicode Character Set.

                    b. Debugging - enter the path to Python in the Command field. (e.g. C:Python27python.exe). Then set Attach to Yes.

                    c. Linker > General - change the Output File to end in .pyd instead of .dll.

                  6. Ensure that your configuration is set to Debug. Go to Build > Build Solution.

                  7. Open a cmd and cd into the directory where your pyd file was compiled. Start python from the cmd window. To attach debugger on this running python process, go back to Visual Studio and click the green play button to start debugging. You can also use Debugging -> Attach to Process... Now go back to Python and import your module. Play, test, and try to break it!

                  这篇关于如何在 Windows 上调试 Python 的 C 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)

                    <tfoot id='v2aId'></tfoot>
                    <i id='v2aId'><tr id='v2aId'><dt id='v2aId'><q id='v2aId'><span id='v2aId'><b id='v2aId'><form id='v2aId'><ins id='v2aId'></ins><ul id='v2aId'></ul><sub id='v2aId'></sub></form><legend id='v2aId'></legend><bdo id='v2aId'><pre id='v2aId'><center id='v2aId'></center></pre></bdo></b><th id='v2aId'></th></span></q></dt></tr></i><div id='v2aId'><tfoot id='v2aId'></tfoot><dl id='v2aId'><fieldset id='v2aId'></fieldset></dl></div>
                    • <legend id='v2aId'><style id='v2aId'><dir id='v2aId'><q id='v2aId'></q></dir></style></legend>
                      • <bdo id='v2aId'></bdo><ul id='v2aId'></ul>

                        <small id='v2aId'></small><noframes id='v2aId'>

                            <tbody id='v2aId'></tbody>