OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to debug a module that is imported using a notebook file in vcode

  • Thread starter Thread starter elksie5000
  • Start date Start date
E

elksie5000

Guest
I'm sure this is a basic question but I've not found anything that helps me solve a problem.

I've built a utilities.py script to hold functions that I need to regularly perform on a dataset. It is largely in pandas.

I then have a notebook, call it process.ipynb, that imports the script with import utilities as ut

So far so good.

I've got a step in the process that I know I want to fix but I want to see what a variable containing a dataframe looks like.

The instructions should be simple:

  1. Click to set the red breakpoint function in the script where I want the code to stop.
  2. Go to the notebook and in the cell that runs the code and click the left hand side of the cell and click 'debug cell'.
  3. Code runs

And in system output I get

Code:
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

So far, so good.

The code reaches breakpoint and I think I can interrogate variables.

Nothing shows in the variables window.

enter image description here

I've tried dir() but I don't recognise any variables, and similarly unrecognise outputs from locals()

I've typed mgd but get the response:

Code:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'mgd' is not defined

I'm keen to avoid using print statements where possible but this is confusing. What's the next step?
<p>I'm sure this is a basic question but I've not found anything that helps me solve a problem.</p>
<p>I've built a utilities.py script to hold functions that I need to regularly perform on a dataset. It is largely in pandas.</p>
<p>I then have a notebook, call it process.ipynb, that imports the script with import utilities as ut</p>
<p>So far so good.</p>
<p>I've got a step in the process that I know I want to fix but I want to see what a variable containing a dataframe looks like.</p>
<p>The instructions should be simple:</p>
<ol>
<li>Click to set the red breakpoint function in the script where I want the code to stop.</li>
<li>Go to the notebook and in the cell that runs the code and click the left hand side of the cell and click 'debug cell'.</li>
<li>Code runs</li>
</ol>
<p>And in system output I get</p>
<pre><code>0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
</code></pre>
<p>So far, so good.</p>
<p>The code reaches breakpoint and I think I can interrogate variables.</p>
<p>Nothing shows in the variables window.</p>
<p><a href="https://i.sstatic.net/829NMFlT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/829NMFlT.png" alt="enter image description here" /></a></p>
<p>I've tried dir() but I don't recognise any variables, and similarly unrecognise outputs from locals()</p>
<p>I've typed mgd but get the response:</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'mgd' is not defined
</code></pre>
<p>I'm keen to avoid using print statements where possible but this is confusing. What's the next step?</p>
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top