The Artima Developer Community
Sponsored Link

Python Answers Forum
Python doesnt seem to work on my PC >:/

5 replies on 1 page. Most recent reply: Oct 7, 2004 5:11 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Michael Garwood

Posts: 2
Nickname: cupofsquir
Registered: Oct, 2004

Python doesnt seem to work on my PC >:/ Posted: Oct 5, 2004 11:52 PM
Reply to this message Reply
Advertisement
Ok, im getting started on Python, the only problem is python doesnt seem to like my PC:

I wrote a simple prog with "Print "Hello"" just to see how Python worked, only to find the DOS box which opened to run the script simply closes a few seconds later. I have also tried several programs in the lib folder all with the same affect. I do notice some writing appearing in some of the programs when they run but the box closes so quickly I have no time to read them.

I am using Windows XP Home Edition Service Pack 2, with 1.7ghz CPU and 256RAM.

Any help please?
Thanks ^^


Andy

Posts: 28
Nickname: adn
Registered: Jul, 2004

Re: Python doesnt seem to work on my PC >:/ Posted: Oct 6, 2004 6:06 AM
Reply to this message Reply
Hi,

Sounds like you're saving a '.py' file then double clicking it to run it. This runs the script fine but the window gets closed afterwards.

You should have a program group in your start menu? Run either IDLE or the python command line for an interactive session where you can play around with python.

*or*

put 'raw_input()' at the end of your program. It'll wait for you to press return before it continues (and ends). Not the intended use for it though.

*or*

Bring up a command line and run your programs from there. It should be enough to run 'hello.py' for it to run.

Michael Garwood

Posts: 2
Nickname: cupofsquir
Registered: Oct, 2004

Re: Python doesnt seem to work on my PC >:/ Posted: Oct 6, 2004 8:04 AM
Reply to this message Reply
aaah thanks :) silly python. Looks like i AM going to need to print the tut out then -.-

Girts Kalnins

Posts: 23
Nickname: smejmoon
Registered: May, 2003

Re: Python doesnt seem to work on my PC >:/ Posted: Oct 7, 2004 3:53 AM
Reply to this message Reply
or write batch file ;)
--stuff.bat--
python my.py
@pause

phil jones

Posts: 14
Nickname: interstar
Registered: Apr, 2003

Re: Python doesnt seem to work on my PC >:/ Posted: Oct 7, 2004 3:40 PM
Reply to this message Reply
Well, while we're on the subject of naivety about Python in windows, I can't figure out how to include other modules which are in subdirectories of the directory where the main program is.

On Unix, I have the main program use the os library and use sys.path.append the various subdirs I keep my other modules. This doesn't seem to work in Windows. (And probably isn't the right way to do things anyway.)

So how should I tell my program where to find modules in subdirectories that will work in both Linux and Windows

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Python doesnt seem to work on my PC >:/ Posted: Oct 7, 2004 5:11 PM
Reply to this message Reply
> aaah thanks :) silly python...

You mean silly Windows. This is not behavior of Python, it is the behavior of Windows. The same will happen with any script or console application, whether it is Python, Perl, Ruby, or a batch file, etc. If you are doing console stuff in Python (which is probably the case, if you are learning it), it will probably be easier if you work from a "Command Prompt" window that is open all the time for running scripts and seeing their output. Of course, as suggested above IDLE is great for interactive learning. There is also PythonWin which also has an editor; that comes with the Python Win32 extensions (which you'll need if you plan on doing serious Windows-specific work).


> ... I can't figure out how to include other modules
> which are in subdirectories...
>
> On Unix...
>
> So how should I tell my program where to find modules
> in subdirectories that will work in both Linux and Windows


You can set this up to work in both environments. Why don't you post what you already have and we'll figure out why it isn't doing what you want on windows. I haven't tested this, but I'd try something like this:
sys.path += [os.path.abspath(p) for p in os.listdir(os.curdir)]

If I wanted to get every sub-directory one level deep into the python path. If you want to go deeper, then use os.walk()...

Flat View: This topic has 5 replies on 1 page
Topic: Reading from a text file Previous Topic   Next Topic Topic: want to catch new thread event

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use