Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm not recognising .py extension

Tags:

python

pycharm

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

like image 548
Jan Kreischer Avatar asked Oct 24 '25 19:10

Jan Kreischer


1 Answers

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

like image 150
wim Avatar answered Oct 26 '25 07:10

wim