I just started learning python for the online course provided by 10gen education, MongoDB for developers (python), i have installed python 2.7 successfully and set the environment vars(path: C:\python27), i can open the python shell and execute the commands and stuff but when i created a python script file named (test.py) and open the command promt, navigated to the current directory C:\10gen and when i try to run it using python test.py it shows me an error
python: can't open file 'test.py': [Errno 2] No such file or directory
however if i execute the same obove command with .txt extension like python test.py.txt it works fine. my question is how would i make filename.py execute from command line .
PS:, my script file contains simple function which iterates over an list and prints it.
Thanks in advance
This has happened because you used Notepad and tried to save the file as (.txt) TextFile option in Save menu.
use double quotes around “file.py” or select
All Filesfrom the dropdown(of Save as type) in the Save As Dialog box.I recommend using EMacs for Python development. You can also start off with IDLE 🙂