Computer Hope

Software => Computer programming => Topic started by: Liquidius on December 08, 2013, 05:11:51 PM

Title: Python programs won't run.
Post by: Liquidius on December 08, 2013, 05:11:51 PM
I had a power outage and temperatures a bit below freezing in my home.  My computer was exposed to those temps for a short while.  When I started it up, Windows 7 had to repair some problems.  Since then, any program I write in Python will not run in IDLE or otherwise.  I have uninstalled Python and re-installed several times.  I have tried to run down every piece of the program and delete it also (I might not be good at that).  Still nothing.  The older programs that I wrote before the recent weather work fine.  Anything new will not run.  My computer seems to be working fine otherwise.
Title: Re: Python programs won't run.
Post by: Geek-9pm on December 08, 2013, 08:48:16 PM
What version of Python do you have?
Also, are you running 32 bit or 64 bit?
Because there are different ways people use Python, some more detail is needed.
Does the tone of this page represent the way you do Python?

Python on Windows FAQ (http://docs.python.org/2/faq/windows.html)

Is the problem only with any recent files you made into an EXE?
Or is it also with even the source files will not compile?

My best guess is that some of your files were corrupted by the power surge. The files may have hidden characters that prevent the interpreter from parsing correctly. You may need to pass your source  files through some kind of filter.
Title: Re: Python programs won't run.
Post by: Liquidius on December 08, 2013, 09:14:34 PM
I was using version 2.5.something because I don't know a lot and was just tinkering at first.  When it started functioning improperly, I replaced it with 2.7.something.  I was downloading from python.org.  Someone suggested that I try ActiveState.  I downloaded the newest version of 2.7 that they have.  A new python program will run now but still will not run in IDLE.  I have tried 32 bit and 64.
Title: Re: Python programs won't run.
Post by: Liquidius on December 08, 2013, 09:47:15 PM
I'm afraid Windows or my hard drive is messed up.  I got a 4 line program to run.  Anything beyond that gives me a syntax error without even running the 4 lines I proved worked earlier (they were input lines).
Title: Re: Python programs won't run.
Post by: BC_Programmer on December 08, 2013, 10:19:08 PM
Post some examples of working and non-working script code.

Title: Re: Python programs won't run.
Post by: Liquidius on December 08, 2013, 10:55:08 PM
Working:

width = input('What is the width of the film you will be using in inches? : ')
lengthfilmfeet = input('What is the length of the film in feet?: ')
lengthfilminches = float(lengthfilmfeet) * 12.0
print lengthfilminches
input('Press <enter> : ')


Not Working:

width = input('What is the width of the film you will be using in inches?  Add a decimal place to your entry please. : ')
lengthfilmfeet = input('What is the length of the film in feet?  Remember to add a decimal place to your entry. : ')
lengthfilminches = float(lengthfilmfeet) * 12.0
1000s = float(lengthfilminches) * float(width) / 1000.0
print 1000s
input('press <enter>: ')

I get an immediate syntax error and it closes.  Neither of those will run in IDLE.
Title: Re: Python programs won't run.
Post by: Liquidius on December 09, 2013, 04:36:16 AM
This turned out to be a user error on my part.  I spent 13 hours trying to solve this today.  So there.
Title: Re: Python programs won't run.
Post by: Salmon Trout on December 09, 2013, 05:54:41 AM
This turned out to be a user error on my part.

Care to share?
Title: Re: Python programs won't run.
Post by: Liquidius on December 09, 2013, 06:45:49 AM
First:  I did have a syntax error.  I don't remember exactly what it was.
Second:  I was selecting "Python shell" from the run menu equating that with "Run in shell"
Third:  I made that mistake only minutes after Windows performing repairs.  So my line of reasoning was diverted to that.
Fourth:  When I re-installed Python, I upgraded and there might have been a change in appearance.
Fifth:  Some other excuse.
Title: Re: Python programs won't run.
Post by: BC_Programmer on December 09, 2013, 09:24:47 AM
First:  I did have a syntax error.  I don't remember exactly what it was.
it was the variable name "1000s", which isn't a valid variable name.



Title: Re: Python programs won't run.
Post by: Salmon Trout on December 09, 2013, 11:24:31 AM
First:  I did have a syntax error.  I don't remember exactly what it was.
Second:  I was selecting "Python shell" from the run menu equating that with "Run in shell"
Third:  I made that mistake only minutes after Windows performing repairs.  So my line of reasoning was diverted to that.
Fourth:  When I re-installed Python, I upgraded and there might have been a change in appearance.
Fifth:  Some other excuse.

Summary: I don't care about wasting everybody's time.
Title: Re: Python programs won't run.
Post by: Salmon Trout on December 09, 2013, 11:25:34 AM
it was the variable name "1000s", which isn't a valid variable name.

Indeed.

How hard is it to understand this?

Variable names can be arbitrarily long. They can contain both letters and numbers, but they have to begin with a letter.


Title: Re: Python programs won't run.
Post by: Geek-9pm on December 09, 2013, 01:15:45 PM
Well, it was a goo read anyway.
Toe Err is Human -
computers never forgive.
Title: Re: Python programs won't run.
Post by: Liquidius on December 09, 2013, 07:08:58 PM
Gentlemen, it was the variable indeed, but I think there might have been some change in the Run menu from 2.5 to 2.7.  That might not be the case though.  I did state that I don't know much. 

This turned out to be a great exercise in resourcefulness.  I went into 3 IRC chat rooms, emailed 2 groups, queried 3 friends, posted in a forum, did a system restore and became more familiar with a registry.  Maybe you can appreciate that.  Maybe, also, you can appreciate my embarrassment after discovering that I was making a beginner's mistake, and that I had wasted everyone's time as a result...and, perhaps, you will note that I took the time to mark this as "resolved" and confess my ignorance.  I was tired after 13 hours and agitated and in an incommunicable state.  Perhaps you'll forgive.  I did thank you guys, I think.  Thanks again for the attempts.