[Python] ImportError and sys.path

Pietro peter.zamb a gmail.com
Mar 9 Feb 2016 18:18:40 CET


Ciao Roberto,

On Tue, Feb 9, 2016 at 6:12 PM, Roberto Polli <robipolli a gmail.com> wrote:
> strace -e open python3 test_imp.py |& grep libgreen

grazie per la risposta fulminea!

non so bene come interpretare l'output di strace...

{{{
$ strace -e open python3 test_imp.py |& grep libgreen
    imp.find_module('libgreen')
ImportError: No module named 'libgreen'

$ strace -e open python3 test_imp.py
open("tls/x86_64/libpython3.5m.so.1.0", O_RDONLY|O_CLOEXEC) = -1
ENOENT (No such file or directory)
open("tls/libpython3.5m.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
such file or directory)
open("x86_64/libpython3.5m.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT
(No such file or directory)
open("libpython3.5m.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/tls/x86_64/libpython3.5m.so.1.0",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/tls/libpython3.5m.so.1.0",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/x86_64/libpython3.5m.so.1.0",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libpython3.5m.so.1.0",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libpython3.5m.so.1.0", O_RDONLY|O_CLOEXEC) = 3
open("tls/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
such file or directory)
open("tls/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
such file or directory)
open("libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libpthread.so.0",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or
directory)
open("x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
or directory)
open("libc.so.6", O_RDONLY|O_CLOEXEC)   = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
or directory)
open("x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("libdl.so.2", O_RDONLY|O_CLOEXEC)  = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libdl.so.2",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("tls/x86_64/libutil.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
such file or directory)
open("tls/libutil.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
or directory)
open("x86_64/libutil.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("libutil.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libutil.so.1",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libutil.so.1", O_RDONLY|O_CLOEXEC) = 3
open("tls/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
open("tls/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or
directory)
open("x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
or directory)
open("libm.so.6", O_RDONLY|O_CLOEXEC)   = -1 ENOENT (No such file or directory)
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/lib/libm.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/gconv/gconv-modules", O_RDONLY|O_CLOEXEC) = 3
open("/dev/urandom", O_RDONLY|O_CLOEXEC) = 3
open("/usr/bin/pyvenv.cfg", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("/usr/pyvenv.cfg", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
open("/home/pietro/docdat/src/gis/grass71/dist.x86_64-pc-linux-gnu/etc/python",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/home/pietro", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/encodings/__pycache__/__init__.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/codecs.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/encodings",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/encodings/__pycache__/aliases.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/encodings/__pycache__/utf_8.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/encodings/__pycache__/latin_1.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/io.cpython-35.pyc", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/abc.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/site.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/os.cpython-35.pyc", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/stat.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/posixpath.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/genericpath.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/_sitebuiltins.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/sysconfig.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages/PyUtilib-5.2.3601-py3.4-nspkg.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/types.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/functools.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/collections/__pycache__/__init__.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/operator.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/keyword.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/heapq.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/plat-linux",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/lib-dynload",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/lib-dynload/_heapq.cpython-35m-x86_64-linux-gnu.so",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/reprlib.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/__pycache__/weakref.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/collections",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 4
open("/usr/lib/python3.5/collections/__pycache__/abc.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 4
open("/home/pietro/.local/lib/python3.5/site-packages/Pyomo-4.2.10784-py3.4-nspkg.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages/easy-install.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages/zope.interface-4.1.3-py3.5-nspkg.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages/logilab_common-1.1.0-py3.5-nspkg.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages/matplotlib-1.5.1-py3.5-nspkg.pth",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages/pygtk.pth", O_RDONLY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages/calliope-0.3.7.dev0-py3.5.egg",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/home/pietro/.local/lib/python3.5/site-packages",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/site-packages/gtk-2.0",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("test_imp.py", O_RDONLY)           = 3
open("test_imp.py", O_RDONLY)           = 3
open("/usr/lib/python3.5/__pycache__/imp.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/importlib/__pycache__/__init__.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/warnings.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/importlib",
O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/importlib/__pycache__/machinery.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/importlib/__pycache__/util.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/importlib/__pycache__/abc.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/contextlib.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/tokenize.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/re.cpython-35.pyc", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/sre_compile.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/sre_parse.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/sre_constants.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/copyreg.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/python3.5/__pycache__/token.cpython-35.pyc",
O_RDONLY|O_CLOEXEC) = 3
Traceback (most recent call last):
  File "test_imp.py", line 6, in <module>
open("test_imp.py", O_RDONLY|O_CLOEXEC) = 3
    imp.find_module('libgreen')
  File "/usr/lib/python3.5/imp.py", line 296, in find_module
open("/usr/lib/python3.5/imp.py", O_RDONLY|O_CLOEXEC) = 3
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named 'libgreen'
+++ exited with 1 +++
}}}


Maggiori informazioni sulla lista Python