PYTHONSTARTUP doesn't seem to work

独自空忆成欢 提交于 2019-12-10 13:32:33

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/453808/pythonstartup-doesnt-seem-to-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!