sigmoid
sigmoid

Reputation: 63

Trace where print is occurring?

Given the novice that I am, I have an extremely naive question, apologies for that

I modified certain core .py files by adding print. Now it's printing a bunch of lines and I'm unable to trace what file I added the print statement. How can I find out what line / file the print is occurring, so that i can go back and remove it? It happens when code executes import sklearn.

I tried debugging and going back to certain files I had modified and searching for print statement, but not able to trace back.

Upvotes: 3

Views: 197

Answers (2)

ti7
ti7

Reputation: 18816

Reinstalling sklearn is probably the simplest and easiest option.

Otherwise you can try using pdb to find the troublesome line(s).

python -m pdb myscript.py

Simply mash s (per-function) and n (line-by-line search) to taste until you find the undesirable statements.

Upvotes: 1

David
David

Reputation: 437

OPTIONS:

  1. Remember what you were trying to do when you went in and edited the .py files in the first place, and that might give you a recollection of which files you changed.
  2. Search the python folder and sort by date stamp. The py files that have been recently changed are LIKELY to be the ones you edited. Then go in and revert the edit you made
  3. Flush your Python install and reinstall from scratch. (The 'Nuke the planet from orbit, it's the only way to be sure' option)

In general its a BAD idea to go in and edit the core Python files unless you REALLY know what you are doing.

Upvotes: 1

Related Questions