Showing results for 
Search instead for 
Did you mean: 

How to Debug Python in NX?


Is there a way to debug Python running in NX?  


SInce it is running from NX, I've not found a way to connect to the code like you would from Visual Studio C++. I'm using PyCharm but am glad to switch to something else if there is a way to step through my code.  




Re: How to Debug Python in NX?


I figured it out using Visual Studio 12.  For anyone else looking to do this, here is what I did. I'm guessing it is something similar with other IDEs or on other platforms.


1.) Get the Python Tools for Visual Studio


2.) Get the pdbs for Python for mixed mode debugging.  I'm using NX10 which currently uses Python 3.3.2 64 bit.  (see below for how to get your version).


3.) Follow the instructions in the above link on setting up the symbols.


4.) Run NX.


5. In VS, click "Attach to Process" and select "Native code" and "Python code".  Then select the ugraf.exe process


5.) Run your python code in NX.VS should stop at any breakpoints you set.   


Note that if you get the wrong PDBs or don't set the path right in VS, I either got an error or a message in VS saying PDB not loaded.


If you are reading this in the future (I hope NX19 is really coolSmiley Happy!), you can get the exact Python version being used by NX by clicking the "Developer" tab, then Edit and pasting the following code, then checking the NX log (File/Help/Log File)




print (sys.version) #parentheses necessary in python 3.


Python(stdout): 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)]



Re: How to Debug Python in NX?

Siemens Phenom Siemens Phenom
Siemens Phenom



Thanks for taking the time to share this!