I have several django projects and several different files with name utils.py
, however pycharm treats them as simple .txt
files with no syntax highlighting or any other kind of parsing, how can I fix this?

- 4,147
- 7
- 27
- 43

- 11,384
- 12
- 45
- 58
6 Answers
Please see File
| Settings
(Preferences
on Mac) | Editor
| File Types.
Look for your file name mapped to the Text type or to the Auto-detect file type by content type.
Remove the incorrect mapping and it will fix the issue.
If you still can't find the wrong mapping in the IDE settings, locate the options/filetypes.xml
file in the Configuration directory. Close the IDE and either edit this file to remove the incorrect mapping or delete this file to reset all the file types to the defaults.
- You can also use Revert File Type Override / Override File Type file context menu actions.

- 389,263
- 172
- 990
- 904
-
5the pattern there is CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;*$py.class; however utils.py was registered under Text file pattern , removed it. – Vaibhav Mishra Nov 14 '12 at 09:36
-
1This is generalizable to other file types getting associated with the wrong extension as well. I had the same problem with one of my .js files getting associated with the plain text file type and this solution fixed my problem. – Justin Houk Nov 19 '12 at 19:51
-
1Ran into this accident today. Thought the filename extension would normally pickup the "Python Type" from the file-association choices, but I must of accidentally type the filename in the type Textfield. – chamberlainpi Apr 13 '15 at 18:01
-
2PHPStorm also has this issue - adding this here to hopefully help future googlers. – djsmiley2kStaysInside Nov 19 '15 at 10:17
-
3Per @Nicolas's soon-to-be-deleted comment-as-answer: "In Pycharm 4.5, the `File Type` menu is in `Pycharm` | `Preferences` | `Editor`" – Paul Roub Mar 21 '16 at 20:32
-
Thanks, worked for me. But this thread has been going on for years at Jetbrains, a right-click "change file association" would be nice :-0 https://intellij-support.jetbrains.com/hc/en-us/community/posts/206237949-Change-file-association-manually – Sonia Hamilton Oct 02 '19 at 04:07
-
I can't find the text files. In the File types there is a list of all the Recognised File types and in the list there is TEXT but not Textfiles. In Text i can't find any utils.py. i am using mac and intelliJ – Malick Usman May 11 '21 at 10:50
-
@MalickUsman Please see the updated answer. – CrazyCoder May 11 '21 at 17:42
-
I was having this problem for Grials JSON Views, `.gson` files. I couldn't find it via the UI, but I was able to find the association in the IDE settings file `~/Library/Application Support/JetBrains/
– SGT Grumpy Pants Oct 24 '22 at 14:58/options/filetypes.xml`. I deleted the incorrect entries and restarted the IDE, and it was back to normal. Thanks!
As CrazyCoder answered, my file also landed in an unintended association. In my case it was "Auto-detect file type by content". You can just try to add your file to the desired file type (e.g. Python) and PyCharm will automatically try to move the association.

- 31
- 2
FYI, a quick action to reassociate a file's type will be available in the context menu of the Project tool window in IntelliJ IDEA 2021.2 (EAPs should be available publicly around May 2021).

- 5,275
- 2
- 8
- 17
In my case I had to right click the file in question (a django migration) and select Mark as Python
.
I probably clicked Mark as Plain Text
before by mistake.

- 676
- 1
- 6
- 19
I actually solved this by going to the Project section , and then clicking Override File Type by right clicking on the specific file. Then I selected the type of the file from the list of available file types.
That worked

- 29
- 3
For me, the file somehow forgot its type. This can be overridden by
Right click the file name --> Override File Type --> Select file type.

- 23,452
- 27
- 113
- 201