Skip to content Skip to sidebar Skip to footer

Naming A New File In Pycharm

I just started learning python. Up until now, I primarly worked with jupyter notebooks, but now wanted to try out some IDEs. So I tried out PyCharm. So I started creating some file

Solution 1:

For me I have to right click on a directory (folder) and select New -> Python File to make a python file. If I go New -> File it will create a text document. So long as you click the correct option you shouldn't have to worry about typing the '.py' or '.txt'

Alternatively I can right click and select New -> File and then name it "simple_message.py" and it will save as a python file correctly, but I must include the .py using this method

Solution 2:

Currently PyCharm context menu lets you choose the file type to create. If you choose "file" you MUST provide the extension .py If You choose "Python File" pycharm handles the extension for You.

Right click on the pycharm projects tab

Solution 3:

You may need to right click in the text of your .py file and manually choose run from the menu.

Pycharm doesn’t automatically reindex when you create a new .py file, and so it probably just doesn’t know what you want it to run when you hit the green play button.

If you’re saying your python interpreter won’t run a .py file because it has an underscore in the name, that’s just not possible unless you have a modded interpreter or have done something really strange to your OS and I’m guessing you haven’t done either.

Update: it sounds like you don’t have the .py file extension on your file. This will not run for reasons that have nothing to do with Pycharm. Pycharm may “bridge the gap” for you automatically in some situations, but no reason to rely on that.

Post a Comment for "Naming A New File In Pycharm"