here's a quick background: I am on day 1 of learning Python. No prior coding experience. Running Windows 8. Python 2.7 installed (location: C:\Python27). I have added the path "C:\Python27\;" to the environment variables and '.py:' to PATHEXT. I am able to launch Python.
To learn, I'm starting with the Google Developers course on Python. I've downloaded the google-python-exercises file to my desktop which has a file 'hello.py'. The Google page(https://developers.google.com/edu/python/set-up) says I should be able to enter 'python hello.py' in the command prompt and it should print 'Hello World'.
When I attempt this, I get the message: python: can't open file 'hello.py: [Errno 2] No such file or directory
. How can I fix this?
Update
I'm able to run it by running cmd from the folder. However, this seems to be a temporary solution. How do I program Python to take a new folder (C:\Python27\MyProjects) and search it? It sounds like I need to add/edit a directory, but I'm not sure how to do this.
I resolved this problem by navigating to C:\Python27\Scripts folder and then run file.py file instead of C:\Python27 folder
From your question, you are running python2.7 and Cygwin.
Python should be installed for windows, which from your question it seems it is. If "which python" prints out /usr/bin/python , then from the bash prompt you are running the cygwin version.
Set the Python Environmental variables appropriately , for instance in my case:
In that case run cygwin setup and uninstall everything python. After that run "which pydoc", if it shows
Replace /usr/bin/pydoc with
Then add this to $PY_HOME/Scripts/pydoc.bat
Now when you type in the cygwin bash prompt you should see:
Prior to running python, type
cd
in the commmand line, and it will tell you the directory you are currently in. When python runs, it can only access files in this directory.hello.py
needs to be in this directory, so you can movehello.py
from its existing location to this folder as you would move any other file in Windows or you can change directories and run python in the directoryhello.py
is.Edit: Python cannot access the files in the subdirectory unless a path to it provided. You can access files in any directory by providing the path.
python C:\Python27\Projects\hello.p