Using the gedit editor I have made a file ex1.py. My system is Linux Ubuntu 16.04 LTS. I have tried many solutions including giving the full path like python /home/xyzpc/mystuff/learnpython/ex1.py. For understanding purpose mystuff and learnpython are the two folders I have created and inside learnpython I have kept the ex1.py file. BUT again it is showing python: can't open file 'ex1.py': [Errno 2] No such file or directory. Please help. I know it is a duplicate one but unable to fix the issue
Open the terminal and type
python (python followed by a space), then drag the ex1.py file into the terminal and press Enter. If the command executes successfully you now know two things.
ex1.py executed successfully.
When you drag a file from the file manager into the terminal it automatically prints the complete path to that file. In order to access ex1.py using
cdchange directories to the directory that contains ex1.py which can be identified from the path to ex1.py.