Debugging a 3rd party library in Python

in Development


You use a 3rd party library in your Python project and at one point you want to see exactly what it does.

For example, you want to see what Yahoo Finance API URLs does yahooquery call internally. It uses a _get_data() function that uses some other function to build the URL and you just want to see it. What if there was a way to simply print() what's going on or better, see everything in a breakpoint!

Finding your package locally

Open Terminal and run:

python3 -c "import yahooquery, inspect; print(yahooquery.__file__)"

On a Mac, you ger something like:

/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.13/lib/python3.13/site-packages/yahooquery/__init__.py

This is where your package source is.

Finding your package in Azure Web App Service

It's likely in antenv/lib/python3.13/site-packages/my-package

(Assuming you're using Python 3.13.)

Debugging your package source from within PyCharm

  • Open ViewTool windowsProject (this is where you navigate project files)
  • Expand External Libraries and look for your package under site-packages
  • Open the package file you want to debug and set your breakpoint

Now when you Debug (as opposed to just Run) your script that uses the package, it will stop on that breakpoint.

#microsoft-azure #python #pypi #pycharm