ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] Windows questions
by Jeff Shannon other posts by this author
Sep 2 2003 5:37PM messages near this date
Re: [Tutor] Windows questions | [Tutor] plotting pixels
Robin Hood wrote:

>  1. How do you set the PATH environment variable for python under windows 98
>  (So that I can import modules which aren't located in the same folder as
>  python itself)

The simplest way to do this is to include a file named python.pth in 
your Python directory -- the filename itself doesn't matter, as long 
as the extension is '.pth'.  Each line of this file should contain a 
directory name; every directory that's specified in that file will be 
added to your sys.path, and thus searched for modules.

You can also create (in your autoexec.bat or the like) an environment 
variable named PYTHONPATH, formatted like the PATH variable; those 
directories will also be searched for modules.

>  2. Currently, to execute a python script I have to right click it, choose
>  "edit with IDLE" then choose "run script" from one of the drop down menus.
>  If I just double click on a python script. It automatically executes under
>  the DOS interpreter, and then closes itself too quickly to see what the
>  results were. Is it possible to change this? (That is, make it so that the
>  program doesn't automatically close the DOS Prompt after its finished
>  executing, or get it to automatically execute under the Windows IDLE)

One option is to simply add a final line to the script -- 
'raw_input("Press Enter to close this program")'.  You could also just 
always start scripts from a command prompt, but that's a bit of a 
pain.  For a more permanent solution, you need to convince Windows to 
run your scripts with the -i option to Python -- that option will 
leave Python in interactive mode once the script finishes running.  To 
do this, you need to go to Windows Explorer's Tools menu, select 
'Folder Options', and go to the File Types tab.  Find the entry for PY 
files, click on 'Advanced', then select the 'open' entry and hit the 
Edit button.  You'll see the command line that Windows uses when you 
open files of this type.  Now, insert '-i' just after 'python.exe'. 
You'll probably want to do the same thing for compiled python files 
(PYC/PYO).  Instead of altering the existing open command, you could 
create a new command that would use the interactive mode, which would 
let you have the standard behavior for most uses but allow you to 
right-click and select your new command when you need it.

Jeff Shannon
Technician/Programmer
Credit International


_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Robin Hood
Alan Gauld
Jeff Shannon
Jeff Shannon

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved