Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sometimes PyDev doesn't recognise .py files as python source files

Sometimes when I open a python file (.py extension) in the PyDev Package Explorer, that file is opened as a plain text file - without syntax highlighting, breakpoint setting and all the other great PyDev features. I cannot see any differences to other files in the same folder. When I create another .py file (this time PyDev realises that it is a python source file), add an import unrecognised_file statement with a breakpoint, debug the file and choose to "Step into" the unrecognised file, it suddenly comes good and I can see syntax highlighting and can use breakpoints and all.

After closing the unrecognised_file and re-opening it, it is back to dumb text mode an I can't use the PyDev features.

Any clues about what is going wrong? What is the algorithm for determining if a file is a python file or a text file?

like image 831
FriendFX Avatar asked Nov 08 '11 04:11

FriendFX


1 Answers

If this happens (and the association for file marks "Python editor" as the default in the preferences), you can right-click the file and do "open with > other" and choose "Python editor" from the list.

That setting should be persisted for that file later on (what could've happened is that you opened the file as text and Eclipse persists that, so, opening again with the PyDev editor should make the association correct again).

p.s.: the debugger forces opening files with the PyDev editor, but that setting is not persisted as when you open the file through the PyDev Package Explorer (that's why it works when you're in a debug session).

like image 69
Fabio Zadrozny Avatar answered Oct 04 '22 17:10

Fabio Zadrozny