0

When setting breakpoints outside the initially run file, Pycharm opens what appears to be a read-only copy of the file rather than stepping through the actual source code file. Is there any way to prevent this?

For example, I am working in foo.py that imports a library bar.py which is another file in the same directory as foo.py. If I set a breakpoint in bar.py after running debug on foo.py Pycharm will stop in a read-only copy of bar.py rather than bar.py itself. If I try to make any edits it will give me the "Non-project Files Protection" error, and if I ignore this and edit anyway I get strange unsynced changes/errors between this read-only file and the source.

I'd understand if Pycharm were opening a read-only file for something like numpy or some other external dependency, but bar.py is my own source code and I want to make edits to fixes I find while debugging right there rather than opening up the source separately, searching for the same line, and then fixing. Of course I expect to have to rerun the debugger after making changes, but this is a fair nuscence compared to other IDEs I've used for other languages. Maybe it is an unavoidable python issue with compilation at runtime?

topher217
  • 968
  • 8
  • 31
  • There is a chance this is caused by [having Reader Mode activated](https://stackoverflow.com/q/66721578). One of the [Reader mode options](https://www.jetbrains.com/help/pycharm/reader-mode.html) causes installed files to be opened in read-only mode. I think there was also another IDE setting that caused this but in the current PyCharm version I haven't been able to find it. – bad_coder Jul 21 '21 at 18:29

0 Answers0