Robin311
Robin311

Reputation: 253

Saving and opening Python Script in Anaconda

I use Anaconda with Spyder that was installed in Anaconda to learn python.

The problem: when I'm trying to save python scripts by extending the file name to .py, the python script automatically gets saved in the Windows notepad. And when I try to open that again in Spyder it doesn't open.

In other words, in Spyder I saved the script by doing "file - save as - 'filename.py'" and I tried to open the saved script by doing "file - open - 'filename.py'" in Spyder.

However, it doesn't work.

I two questions about this.

  1. Is it normal for python scripts to be saved on windows notepad? If not, what is wrong here and how do you normally save python scripts with Anaconda?

  2. Why doesn't Spyder open the notepad file, the python script I saved? I added the extention .py when I saved it but it is not opening in Anaconda Spyder regardless.

I realize this is a basic question to many and the answer may exist somewhere but I have a very hard time finding it and I'm hoping someone can help me solve this problem. Thanks.

Upvotes: 1

Views: 1391

Answers (1)

user13966865
user13966865

Reputation: 468

Answer to the First question
Is it normal for python scripts to be saved on windows notepad? If not, what is wrong here and how do you normally save python scripts with Anaconda?

Check what default program is set for opening .py file in your system you can change it by
rightclicking on .py file >expand open with > choose open with another app and tick the option 'always use this for .py file'

Second question
Why doesn't Spyder open the notepad file, the python script I saved? I added the extention .py when I saved it but it is not opening in Anaconda Spyder regardless.

Check type of file your saving "the field below filename it should be allfiles(*)" probably your script is saving "filename.py.txt" which is not a proper format for python file

Upvotes: 1

Related Questions