Results 1 to 12 of 12
-
2017-12-08, 09:02 PM (ISO 8601)
- Join Date
- Sep 2013
Trying to Learn Python: Problems running Python Scripts
Hello,
I am trying to learn the basics of using Python (version 2.7) using Google's free course (link to the overview). If you check out the set up, they talk about a script "hello.py" to run to see if things are installed properly.
I can pull up python on my computer and use it for basic commands, such as setting values and do math with those values, but I cannot get it to find the hello.py script on my computer when I type "python hello.py" into Python.
Any ideas where I have made an error?
Thanks for the assistance!
-
2017-12-08, 10:11 PM (ISO 8601)
- Join Date
- Mar 2007
- Location
- Oregon, USA
Re: Trying to Learn Python: Problems running Python Scripts
FeytouchedBanana eldritch disciple avatar by...me!
The Index of the Giant's Comments VI―Making Dogma from Zapped Bananas
-
2017-12-08, 11:21 PM (ISO 8601)
- Join Date
- Sep 2013
Re: Trying to Learn Python: Problems running Python Scripts
-
2017-12-09, 12:01 AM (ISO 8601)
- Join Date
- Mar 2007
- Location
- Oregon, USA
Re: Trying to Learn Python: Problems running Python Scripts
Well, you could move the file and/or change where the command prompt is running programs from; as long as it's the same place, it should work. A thorough walkthrough of command prompt navigation is...too much for me to provide here.
However, since I'm lazy and I see the Google page gives you an entire zipped folder of their Python exercises....What I'd do, assuming you're running Windows, is copy the one "google-python-exercises" folder in their zip file (the folder itself, not just the files in it) to the top of the drive; so you'd have a new "google-python-exercises" folder there. Then when you open the command prompt, you should be able to do
Code:cd \google-python-exercises
Last edited by Jasdoif; 2017-12-09 at 12:02 AM.
FeytouchedBanana eldritch disciple avatar by...me!
The Index of the Giant's Comments VI―Making Dogma from Zapped Bananas
-
2017-12-09, 02:39 AM (ISO 8601)
- Join Date
- Sep 2014
Re: Trying to Learn Python: Problems running Python Scripts
You can also drag and drop a file from "Windows Explorer" into the command line and it'll give the full path to that file. You could type "python" and then instead of typing hello.py open up Windows Explorer, find your hello.py file wherever you saved it and "drag" it into the command line. You should get something like python "C:\Users\Mith\Documents\hello.py" when you do that.
-
2017-12-09, 02:40 AM (ISO 8601)
- Join Date
- Sep 2013
Re: Trying to Learn Python: Problems running Python Scripts
Thank you for your response. I apologise for the silly question. I am thinking the problem is that I am working on the ground floor without a foundation, so to speak. I had the files stored to be in a folder that the initial directory (so the path using the central filing system was (C:)>Users>Mith>google-python-exercises. My reasoning was that "(C:)>Users>Mith>" is where the directory already was when starting the command window. The file and program will just be extended from there.
From what I can gather now that I can get things to work, it needs to be (C:)>google-python-exercises.
If this comes across as incorrect, it's because I written things poorly, since I at least got things working.
Once again, thank you for your assistance. I apologise for any headaches I may have caused.
-
2017-12-10, 07:27 AM (ISO 8601)
- Join Date
- Jul 2008
- Location
- Sweden
- Gender
Re: Trying to Learn Python: Problems running Python Scripts
A quick and easy way to get to the correct directory is hold shift and left click inside the directory. An extra option of "open command line here" (or "open powershell here") will appear that will automatically be in the correct folder.
Black text is for sarcasm, also sincerity. You'll just have to read between the lines and infer from context like an animal
-
2017-12-10, 12:22 PM (ISO 8601)
- Join Date
- Mar 2007
Re: Trying to Learn Python: Problems running Python Scripts
Does your python come with Idle? If so it is probably easier to edit with Idle and simply hit [F5] to run your script.
There must be better python IDEs out there, but I got used to IDLE and still use it (it is *extremely* primitive as an IDE, but I just like primitive tools. And it generally won't get in your way while learning python (you don't waste time figuring out if you issue is with your program or your tool usage).
It might also be better to start with python 3 as the python world might finally be going that way. It isn't *that* big a deal (mostly in how printing is handled, and remembering that you don't have to bother with "xrange"). Since pypy (and plenty of other projects) are still on 2 it isn't a big deal but I suspect that you might be picking up old habits.
-
2017-12-12, 02:27 PM (ISO 8601)
- Join Date
- Oct 2014
Re: Trying to Learn Python: Problems running Python Scripts
There's a basic primer on console commands here, but just remembering 'cd' and 'dir' will get you a long way.
I'd recommend using PyDev with Eclipse, but if you're still figuring out the command-line that might be a little complicated?Give directly to the extreme poor.
-
2017-12-12, 10:47 PM (ISO 8601)
- Join Date
- Sep 2013
-
2017-12-12, 10:49 PM (ISO 8601)
- Join Date
- Sep 2013
-
2017-12-14, 04:00 AM (ISO 8601)
- Join Date
- Aug 2013
Re: Trying to Learn Python: Problems running Python Scripts
back in ye olden days you would have to add the python fodler to the "system environment" variable. Thus you could access the python executible from where ever you happened to be. Not sure how this is done anymore. Hopefully the installation did it for you.
But your problem is basically the same as back when. The python file you are calling is not in the place it's looking because it's only looking in the folder you are currently in.
If you don't have python registered to be able to run from everywhere you'll have the opposite problem trying to run said file from the folder it resides in.