[Bug: 21.4.15] [python-mode] when run from python-mode.C+!, the sys.path is not set from environment

Skip Montanaro skip at pobox.com
Mon Nov 29 15:40:12 EST 2004


    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.)

-- 
Skip Montanaro
skip at mojam.com
http://www.mojam.com/




More information about the XEmacs-Beta mailing list