[Bug: 21.4.15] [python-mode] when run from python-mode.C+!, the sys.path is not set from environment
David A. Cobb
superbiskit at cox.net
Mon Nov 29 19:05:39 EST 2004
Skip Montanaro wrote:
> David> If I set my own python library into the environment var
> David> "PYTHONPATH" then launch 'python' from the shell, the python var
> David> shell.path is set to PYTHONPATH plus other stuff - as the Python
> David> Library Manual says it ought to be.
> ...
> David> However, if I set up an Xemacs Python Shell thus:
> David> Buffer: '*Python*',
> David> python-mode, C+!
> David> I get "Using Cpython Interpreter", yadda yadda yadda ...
> >>>> import sys
> >>>> sys.path
>
> David> shows that the path is NOT being correctly set up.
> ...
>
>Hmm... Works for me (pasted from a shell buffer):
>
> % env | grep PYTHON
> PYTHONSTARTUP=/Users/skip/.python.py
> % . ~/.bashrc
> % env | grep PYTHON
> PYTHONSTARTUP=/Users/skip/.python.py
> % export PYTHONPATH=/path/to/somewhere
> % python
> Python 2.4b1 (#52, Oct 17 2004, 13:54:51)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> sys.path
> ['/Users/skip/misc/python/python2', '/Users/skip/misc/python', '', '/Users/skip/local/lib/python2.4', '/Users/skip/local/lib/python2.4/plat-darwin', '/Users/skip/local/lib/python2.4/plat-mac', '/Users/skip/local/lib/python2.4/plat-mac/lib-scriptpackages', '/Users/skip/local/lib/python2.4/lib-tk', '/Users/skip/local/lib/python2.4/lib-dynload', '/Users/skip/local/lib/python2.4/site-packages', '/Users/skip/local/lib/automatrix/python']
> >>>
> % python -S
> Python 2.4b1 (#52, Oct 17 2004, 13:54:51)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
> >>> import sys
> >>> sys.path
> ['/Users/skip/misc/python/python2', '/Users/skip/misc/python', '', '/Users/skip/local/lib/python2.4/', '/Users/skip/local/lib/python2.4/plat-darwin', '/Users/skip/local/lib/python2.4/plat-mac', '/Users/skip/local/lib/python2.4/plat-mac/lib-scriptpackages', '/Users/skip/local/lib/python2.4/lib-tk', '/Users/skip/local/lib/python2.4/lib-dynload']
> >>>
> % unset PYTHONSTARTUP
> % python -S
> Python 2.4b1 (#52, Oct 17 2004, 13:54:51)
> [GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
> >>> import sys
> >>> sys.path
> ['', '/path/to/somewhere', '/Users/skip/local/lib/python24.zip', '/Users/skip/local/lib/python2.4/', '/Users/skip/local/lib/python2.4/plat-darwin', '/Users/skip/local/lib/python2.4/plat-mac', '/Users/skip/local/lib/python2.4/plat-mac/lib-scriptpackages', '/Users/skip/local/lib/python2.4/lib-tk', '/Users/skip/local/lib/python2.4/lib-dynload']
> >>>
>
>Note that because I fart around with sys.path in my PYTHONSTARTUP file I
>needed to unset that variable to get things to start right. Also, running
>the interpreter with the -S flag when trying to debug these sorts of
>problems will disable import of the site module and thus eliminate it as a
>suspect. (I'm not saying you're necessarily incorrect in your assertion,
>just that you haven't eliminated all local sources that are out of XEmacs's
>and Python's control.)
>
>
Well, lessee -- I don't have a PYTHONSTARTUP and I don't have an "-S" on
the Python command. According to 'custom' -- python group -- the Python
Command Args are ("-i" "-E" "-u").
Oh, spit!!
A quick 'man python' shows that "-E" says to ignore the Environment.
Seems like a dumb default!! But, then, I'm new here in Pythonville, myself.
--
David A. Cobb, Software Engineer, Public Access Advocate
"By God's Grace, I am a Christian man; by my actions a great sinner." -- The Way of a Pilgrim: R.French, Tr.
Life is too short to tolerate crappy software!
More information about the XEmacs-Beta
mailing list