Menu

PYTHONPATH

2011-11-23
2013-03-15
  • Stefan Grewe

    Stefan Grewe - 2011-11-23

    Hi,
    I am using Eclipse Indigo, python3.2 from macports on a macbook pro with lion.
    Trying to run a simple one line program like - print('hi') - gives the traceback below.
    It seems to me that the 'from collections …' in functools should be not be resolved through matplotlib?
    The output following 'searching' stems from a print(PYTHONPATH) which I added to site.py.
    Following the traceback is some output from python interpreterinfo.py
    Please help. Deleting the python interpreter for the project and adding a new interpreter and pythonpath does not change the printed pythonpath in a way I would expect.

    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/site.py", line 73, in <module>
        __boot()
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/site.py", line 33, in __boot
        imp.load_module('site',stream,path,descr)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site.py", line 58, in <module>
        import traceback
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/traceback.py", line 3, in <module>
        import linecache
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/linecache.py", line 10, in <module>
        import tokenize
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/tokenize.py", line 28, in <module>
        import re
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/re.py", line 121, in <module>
        import functools
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/functools.py", line 15, in <module>
        from collections import OrderedDict, namedtuple
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/collections.py", line 13, in <module>
        import numpy as np
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/__init__.py", line 137, in <module>
        from . import add_newdocs
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/add_newdocs.py", line 9, in <module>
        from numpy.lib import add_newdoc
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/lib/__init__.py", line 4, in <module>
        from .type_check import *
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/lib/type_check.py", line 8, in <module>
        import numpy.core.numeric as _nx
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/__init__.py", line 7, in <module>
        from . import _internal # for freeze programs
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/_internal.py", line 169, in <module>
        format_datetime = re.compile(asbytes(r"""
    AttributeError: 'module' object has no attribute 'compile'

    searching 

    ~ $python /Applications/eclipse/plugins/org.python.pydev_2.2.4.2011110216/PySrc/interpreterInfo.py
    Version3.2
    EXECUTABLE:/opt/local/Library/Frameworks/Python.framework/Versions/3.2/Resources/Python.app/Contents/MacOS/Python|
    |/Applications/eclipse/plugins/org.python.pydev_2.2.4.2011110216/PySrcOUT_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python32.zipINS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2INS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/plat-darwinINS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/readlineINS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/lib-dynloadINS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packagesINS_PATH
    |/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/setuptools-0.6c11-py3.2.egg-infoINS_PATH
    @
    $
    |__main__
    |_ast
    |_codecs
    |_collections
    |_functools
    |_io
    |_locale
    |_sre
    |_string
    |_symtable
    |_thread
    |_warnings
    |_weakref
    |builtins
    |errno
    |gc
    |imp
    |itertools
    |marshal
    |operator
    |posix
    |pwd
    |signal
    |sys
    |xxsubtype
    |zipimport
    Traceback (most recent call last):
      File "/Applications/eclipse/plugins/org.python.pydev_2.2.4.2011110216/PySrc/interpreterInfo.py", line 138, in <module>
        raise RuntimeError('Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).')
    RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-11-27

    It does seem weird that the collections imported is not the one from Python. Does it work from the command line?

    Can you run:

    import sys
    print('\n'.join(sorted(sys.path)))

    From both the command line and Eclipse (to try to discover if there's any difference there).

    Cheers,

    Fabio

     
  • Stefan Grewe

    Stefan Grewe - 2011-12-04

    Hi Fabio,

    running as you proposed
    import sys
    print('\n'.join(sorted(sys.path)))
    from the command line gives:
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/lib-dynload
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/plat-darwin
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/readline
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/setuptools-0.6c11-py3.2.egg-info
    /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python32.zip

    Running the same from within eclipse again gives:
    searching 
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/site.py", line 73, in <module>
        __boot()
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/site.py", line 33, in __boot
        imp.load_module('site',stream,path,descr)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site.py", line 58, in <module>
        import traceback
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/traceback.py", line 3, in <module>
        import linecache
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/linecache.py", line 10, in <module>
        import tokenize
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/tokenize.py", line 28, in <module>
        import re
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/re.py", line 121, in <module>
        import functools
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/functools.py", line 15, in <module>
        from collections import OrderedDict, namedtuple
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib/collections.py", line 13, in <module>
        import numpy as np
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/__init__.py", line 137, in <module>
        from . import add_newdocs
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/add_newdocs.py", line 9, in <module>
        from numpy.lib import add_newdoc
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/lib/__init__.py", line 4, in <module>
        from .type_check import *
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/lib/type_check.py", line 8, in <module>
        import numpy.core.numeric as _nx
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/__init__.py", line 7, in <module>
        from . import _internal # for freeze programs
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/_internal.py", line 169, in <module>
        format_datetime = re.compile(asbytes(r"""
    AttributeError: 'module' object has no attribute 'compile'

    It seems many items appear several times, but I don't know where this comes from.
    Any more ideas?

    Thank you very much for your help
    Stefan

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-12-05

    It seems you ran different things from within Eclipse (I can read what you got from the command line, but it's pretty hard to parse what you've run from Eclipse

    Please run:

    import sys print('\n'.join(sorted(sys.path)))

    from Eclipse and post the results again.

    Note: from a quick look, I believe you're adding /opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/matplotlib to the PYTHONPATH, and this directory should NOT be added (you're putting the internal stuff on matplotlib in the PYTHONPATH).

    Cheers,

    Fabio