Jan Kreischer
Jan Kreischer

Reputation: 771

PyCharm not recognising .py extension

community,

I encountered the following issue. I have several classes/ files that I am editing in PyCharm. As you can see PyCharm recognises every file as a valid .py file except the PresidentsPage

Every class except of one is shown as .py file

The problem about that is that auto-completion and code formatting isn't working properly. I already tried to create a new file and copy and pasting the code in there. Sadly that didn't work. Maybe one of you has a smart idea :)

PresidentsPage.py not being recognised as Python file


PlayersPage.py being recognised as Python file


I also checked the extensions in the Preferences. They are perfectly fine enter image description here


When I rename the file to something stupid like 'PjresidentsPage' it is shown as a Python file

enter image description here

Upvotes: 4

Views: 376

Answers (1)

wim
wim

Reputation: 362567

I have seen this issue before, after mistakenly creating a .py module as a plain text file, PyCharm will auto-register that specific filename as a text file.

Navigate to Settings -> Editor -> File Types.

Under Recognized File Types panel, select the Text file type.

Under Registered Patterns panel, find your filename PresidentsPage.py and remove it from the registered patterns (by clicking the "-" icon on right). Click Apply.

Now recreate your file as .py file, not a plain text file.

cap

Upvotes: 7

Related Questions