473,769 Members | 4,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code run from IDLE but not via double-clicking on its *.py

When I double-click on "some.py" file console window appears just for a
moment and right after that it's closed. If this script is started from
inside of IDLE (F5 key) then it executes as it should be (e.g.
executing all its print statements).

Any ideas? OS: Windows; Python 2.3.4. Thanks.

Aug 30 '05 #1
28 5088
max
"n00m" <n0**@narod.r u> wrote in
news:11******** *************@g 47g2000cwa.goog legroups.com:
When I double-click on "some.py" file console window appears just
for a moment and right after that it's closed. If this script is
started from inside of IDLE (F5 key) then it executes as it
should be (e.g. executing all its print statements).

Any ideas? OS: Windows; Python 2.3.4. Thanks.


It's a windows thing. The shell windows opens to run the script in is
closing when the script finishes.

Try opening a shell (Start->Run: cmd.exe on NT/2k/XP or Start->Run:
command.com on 95/98) and then either type the full path to the script
or navigate to it and execute it.

max
Aug 30 '05 #2

n00m wrote:
When I double-click on "some.py" file console window appears just for a
moment and right after that it's closed. If this script is started from
inside of IDLE (F5 key) then it executes as it should be (e.g.
executing all its print statements).

Any ideas? OS: Windows; Python 2.3.4. Thanks.


Your console window closes when the program terminates.
And no, you won't necessarily see any of your print statements
before the window closed. They were buffered and the window
closed before they could be displayed.

Start a console window manually. From the command prompt,
type

some.py

or

python some.py

Aug 30 '05 #3
Thank you, guys, for your replies!

Now it works!

Aug 30 '05 #4
Oops.. not everything so super as I thought.
Incredible but from command line it results as:

D:\>python23\py thon d:\python23\00\ socket6.py
Traceback (most recent call last):
File "d:\python23\00 \socket6.py", line 1, in ?
import socket, thread
File "D:\Python23\00 \socket.py", line 3, in ?
s1 = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
AttributeError: 'module' object has no attribute 'AF_INET'

D:\>

FROM IDLE 1.0.3 THE SAME SCRIPT WORKS PERFECTLY !!!

WHY ON THE EARTH <'module' object has no attribute 'AF_INET'> ???

Aug 30 '05 #5

[n00m]
WHY ON THE EARTH <'module' object has no attribute 'AF_INET'> ???


Because you have a socket.py in d:\python23\00 which is being picked up
instead of Python's own socket module. You shouldn't give your modules
the same name as Python's own modules.

--
Richie Hindle
ri****@entrian. com
Aug 31 '05 #6

Richie Hindle wrote:
Because you have a socket.py in d:\python23\00 which is being picked up
instead of Python's own socket module. You shouldn't give your modules
the same name as Python's own modules.


Yes, Richie! YOU are dmndly RIGHT! Thanks.

Aug 31 '05 #7
Funnily but I still can't get the code working... WITHOUT IDLE.
I think it's because of "import thread" line. Seems something
wrong with "opening" this module. In IDLE it works OK.

Aug 31 '05 #8

[n00m]
Funnily but I still can't get the code working... WITHOUT IDLE.
I think it's because of "import thread" line. Seems something
wrong with "opening" this module. In IDLE it works OK.


It's difficult to diagnose your problem with so little information. Please
post:

o The command you're typing into the command prompt
o The error message you're getting
o The full traceback
o The code you're trying to run, or if it's too big then the piece that
the last line of the traceback refers to

Thanks,

--
Richie Hindle
ri****@entrian. com
Aug 31 '05 #9
n00m wrote:
Funnily but I still can't get the code working... WITHOUT IDLE.
I think it's because of "import thread" line. Seems something
wrong with "opening" this module. In IDLE it works OK.


Now, let's see ... [presses fingers to temples and exercises psychic
powers] ... ah yes, its because you're DOING SOMETHING WRONG :-)

Unfortunately "can't get the code working" isn't a very helpful
description. Can you explain (preferably with a traceback) how it fails?

Generally speaking, when you take your car into the garage (American:
shop) because "it won't go" it's OK because the technicians can try and
start it themselves. We don;t have your code readily to hand, so we need
a bit more to go on.

Generally speaking you would do well to try the threading module rather
than thread unless you have a specific reason for not doing so. But if
you post your code (or even better a subset of your code that
demonstrates the error so people can pick it apart for themselves) with
a traceback from the interpreter or a full description of what you
expected the code to do and what it actually does we'll be able to help
much more easily.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 31 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2632
by: Vin Jovanovic | last post by:
Trying to start Python IDLE through Start>Programs>Python 2.3> IDLE doesn't work From DOS ... I get this .... C:\>python C:\Python23\Lib\idlelib\idle.py Traceback (most recent call last): File "C:\Python23\Lib\idlelib\idle.py", line 23, in ? idlelib.PyShell.main() File "C:\Python23\lib\idlelib\PyShell.py", line 1264, in main
0
1213
by: Ted Gill | last post by:
Platform: Windows ME Python version: 2.3.2-1 Problem: Running GUI apps in Idle does not work. When executing GUI (tkinter/pmw) apps from the edit windows or doing an "import <file>" in the shell window GUI apps freeze and do not respond to internal widgets or window decoration. They also do not repaint. Only way to bail out is to restart the interpreter. Same apps work fine from DOS window or double-clicked in file manager. These...
1
5560
by: Moosebumps | last post by:
So say I am working on two separate .py files in IDLE that are part of the same program. Does anyone have problems where when you modify one file, and then run the other, the changes you made in the first aren't updated? I usually just close all the files, and restart IDLE, but this is a pain. Maybe because I always use right click -> edit with IDLE (on Windows). That starts up a separate Python Shell too, which I always close. MB
1
1499
by: Matt Leslie | last post by:
This code: ************** import thread def doprint(i): print i for i in range(0,100): thread.start_new_thread(doprint,(i,))
1
6731
by: dbrown2 | last post by:
I typically use IDLE for editing and debug. On Windows at least, IDLE and the standard turtle graphics module do not mix. I think both use Tkinter. For now I use IPython and Jedit when using the turtle module but it's not a great solution for me. Is there any known work-around to use turtle with IDLE? If not is there a planned fix for the problem. I find turtle is a convenient way to do simple graphics without having to install...
8
3773
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an installation issue. When the person who has the problem logs into another PC the problem follows them. Any ideas as to what might me wrong? This is the traceback from IDLE: C:\Python20\Tools\idle>..\..\python.exe idle.py Traceback (most recent call...
13
2839
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure UE to run external tools, but I can't figure out how to run IDLE this way, because when I check on its properties to find it's file path, it is just the Python directory itself. So not only do I not know where to find the actual file to run...
5
2796
by: Russ P. | last post by:
I've been programming in python for a few years using XEmacs on Solaris and Linux. I've been thinking about trying IDLE for a long time, but either it wasn't available on my system or I procrastinated. I finally have it available, and I gave it a try. I immediately encountered a basic problem for which I could not find a solution in the intro docs. I want to run a script in one directory that reads input from a file in another directory....
1
3025
by: wongjoekmeu | last post by:
Dear All, I have some functions written in C++, which I try to approach from python using swig. In the C++ functions I use std::cout to print stuff to output. Everything works fine, but the only problem that I have is that when I start IDLE and use the functions what std::cout should print to the "IDLE console" simply does not appear. When I don't use IDLE but simply double click on the .py script, it works all fine. I was wondering how...
2
2955
by: W. eWatson | last post by:
I had just finished working with IDLE, and tried to double-click on a py file. It produced an OK dialog with the path to the file and the msg "access denied." All my py files act that way. I rebooted and the same thing continues. I copied one py program to another computer, and accessed it there. Python 2.4. Suggestions? -- W. eWatson (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.