I had this same problem. I tried removing the pycharm caches in the ~/Library folders to no avail. Kept saying in the log that "Some skeletons failed to generate..."
So, here is what worked.
Go into preferences
In the project settings click project interpreters and then Configure Interpreters
Delete the existing Interpreters (using '-' and bottom) and then click OK at the bottom
If you have a project loaded it will say "You have no interpreter, configure one now. You can click that or go back into preferences->Project Interpreter->Configure interpreters
Click the + to add a new interpreter. If you are using the os x built-in python, you can select the version you want from the list.
Click Ok again, wait a minute or two for rebuilding indexes and viola it works (for me at least)
I had a similar problem where certain .py files were showing up as regular text files after completion, thus rendering the code without syntax coloring, tab completion features, etc. Through using this post as a starting point for debugging the issue, I found the following:
Select the affected File Type from the list on the top half of this dialog box, Recognized File Types (in my case, Text Files)
Listed in the second half of the dialog box, Registered Patterns were the names of the files that I was having naming/syntax issues with. I clicked on each of those and then clicked on the - for each in turn to remove them from the Registered Patterns list.
Click Apply
Sigh of relief when the syntax highlighting returns and the icon changes back to that of a python file.
Had a similar issue after changing the project name and the above didn't help (it kept using an old interpreter). What did help was the following:
In the project folder go to the .idea folder
In the workspace.xml find the interpreter that appears in the error message. Can be found by looking for: option name="SDK_HOME" value="C:\Users\yourInterpreterFolder\python.exe"
Replace the value with the path to your interpreter.
Keep coding happily :)
p.s. my error message was of the following form:
Error running ...: Cannot run program "...\python.exe" (in directory "C:\Users\pathToProject"): CreateProcess error=2, The system cannot find the file specified
I accidently made a text file myfilename, renamed it to the myfilename.py version but it stayed with text file formatting even after the extension change.
Here's how I fixed it for For PyCharm 2017.2 for Windows.
Go to File > Settings > Editor > File Types > Text
Under Registered Patterns, I found the new myfilename.py in the list.
To revive an old conversation here, none of the above answers worked for the newer version of PyCharm due to updates. Upon creating new .py files they were being detected as .txt files and thus not able to run the files, as many others experienced above. I did not get any errors, there was just not any ability to run the file even though it had a .py extension because it was not being detected as a Python file.
PyCharm Version: 2020.1.4
Build: 201.8743.11
Here's what works instead now:
File > Manage IDE Settings > Restore Default Settings
The only problem with this is if you've added a lot of custom settings you'll have to go back in and add them again.
I had a similar problem and none of the answers already submitted helped to resolve it.
I eventually discovered that my affected filename was listed in the
Auto-detect file type by content section in Preferences->Editor->File Types. Removing the filename from there and apply the changes resolved my issue immediately.
I faced a similar issue on PyCharm 2021.1. As mentioned in the other solutions, the .py file that was being rendered as a text file was not present in the following menu:
File | Settings | Editor | File Types | Recognized File Types | Text | File name patterns
The following worked for me instead:
Select the file in the editor | File | File properties | Associate with File Type...
I had a similar situation but the file was not under "Text" in Settings -> Editor -> File Types, it was under "Auto-detect based on file content". Once I deleted it from there, things worked fine.
I had a text file that was not recognized by Pycharm as .py after I changed its ending on Windows.
The solution was to right click on it in the Project menu (the one on the left that details all files in the project).
One of the options was Override File Type. Changing that to Python was successful.
There is a section called "File type auto-detected by file content" under Editor->File Types->Recognized File Types, my file was listed, after removing from there, it got formatted to python
I've tried many methods. My pycharm version is 2020. I've checked the settings and file types, and both are OK. Finally, I got my solution from the link below.
I right-click the XXX_XXX.py (error file) file, click overwrite file type, and then choose python. Problem solved.
I had the same situation here. Ubuntu 18 - PyCharm2022.1.1 (Community Edition).
Solved as mention above with the right click above the file type.
Find the the file to change in the Project tree (Alt + 1).
Then, click in override file type and choose the extension you need.
Select apply and it is done.
Note: Remember to write the correct extension for Python which is .py in most cases. You can check the extension types in File, Settings, Editor, Code Style, File Types.