Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PYTHONSTARTUP doesn't seem to work

Tags:

python

startup

I'm trying to use the PYTHONSTARTUP environmental variable. I set it to be "c:\python25\pythonstartup.py" in My Computer --> Advanced etc., and it doesn't seem to work.

Opening IDLE doesn't run the script, although it recognized the variable:

>>> import os
>>> os.environ['PYTHONSTARTUP']
'c:\\python25\\pythonstartup.py'
>>> 

I'm using XP and Python 2.5.2. I do not wish to upgrade to 3.0 yet.

Thanks

like image 346
R S Avatar asked Jan 17 '09 18:01

R S


2 Answers

The documentation says that PYTHONSTARTUP is only run for interactive sessions. I'm not sure how IDLE runs the Python interpreter, but it could be interfering.

Instead, try running python directly from a command prompt, rather than from clicking on an icon.

like image 189
Greg Hewgill Avatar answered Nov 08 '22 13:11

Greg Hewgill


To add to Greg Hewgill's correct answer: If IDLE doesn't have a startup file of its own, you can put a file called sitecustomize.py in your path which will be executed for both command prompt and scripts / IDLE sessions.

like image 2
dF. Avatar answered Nov 08 '22 13:11

dF.