Menu

#289 odd import?

v3.0
open
nobody
5
2008-08-24
2008-08-24
No

xsx :: banan :~: epydoc -v --html wokoekf/kili.py
+----------------------------------------------------------------------------------------------
| In /home/xsx/wokoekf/kili.py:
| Import failed (but source code parsing was successful).
| Error: ImportError: No module named _protocols (line 25)
|
xsx :: banan :~:

xsx :: banan :~: cat wokoekf/kili.py
#!python

class C(object):
def _g(self):
"""
something here

@rtype: C{int}
@return: blabla
"""

return 0

g = property(_g)

obj = C()
print obj.g
xsx :: banan :~:

there is no import statement in the code? what is that? i have module nmaed _protocols and i generate epydocs for the other package but that package is in completely other directory and there is no relation between them.

Discussion

  • bart skowron

    bart skowron - 2008-08-24

    Logged In: YES
    user_id=1877836
    Originator: YES

    xsx :: banan :~: epydoc --version
    Epydoc, version 3.0beta1

     
  • Edward Loper

    Edward Loper - 2008-08-24

    Logged In: YES
    user_id=195958
    Originator: NO

    Does wokoekf/__init__.py exist? If so, then epydoc will assume that kili is part of the wokoekf package -- i.e., that it would be typically imported using:

    >>> import wokoekf.kili

    And so that's how epydoc will try to import it. (Some modules within packages will only function properly if imported this way.) If that's the case, then Python will import the wokoekf package before it imports the kili module -- so perhaps wokoekf/__init__.py contains a statement importing _protocols?

    If that's not the case, then I'm less sure what could cause this. What happens if you try importing the kili module yourself from a python interpreter shell?

     
  • bart skowron

    bart skowron - 2008-08-24

    Logged In: YES
    user_id=1877836
    Originator: YES

    I know what packages or modules are. There is __init__.py but this file is empy. import from python shell works perfectly.
    i tried to run epydoc as a different system-user and now it works.

    seems like epydoc keeps something in cache or whatever...

     
  • Edward Loper

    Edward Loper - 2008-08-24

    Logged In: YES
    user_id=195958
    Originator: NO

    I figured that you knew what packages were; I just thought you might not realize that epydoc would import the containing package before introspecting a module -- i.e., it would also be possible that it could __import__ the module directly, ignoring the contained package.

    Anyway.. If the __init__.py file is empty, then it seems fairly mysterious to me that importing kili.py would cause epydoc to encounter an import error.

    Try doing this:

    >>> from epydoc.docintrospecter import *
    >>> get_value_from_name('kili')

    or perhaps:

    >>> get_value_from_name('wokoekf.kili')

    And see if you get the import error?

    You could also check to see what file is trying to import _protocols on line 25 -- that would let us know which file is getting accessed that shouldn't be, at least.

     
  • bart skowron

    bart skowron - 2008-08-24

    Logged In: YES
    user_id=1877836
    Originator: YES

    In [2]: get_value_from_name('wokoekf.kili')
    Out[2]: <module 'wokoekf.kili' from 'wokoekf/kili.pyc'>

    also there is no line number 25 in kili.py
    do you talk about different file?

     
  • Edward Loper

    Edward Loper - 2008-08-24

    Logged In: YES
    user_id=195958
    Originator: NO

    Ok, that looks like epydoc is not having trouble importing kili. I was talking about line 25 because the error message you got said:

    Error: ImportError: No module named _protocols (line 25)

    That suggests that when epydoc was trying to import kili, it ended up importing some other python file X; and file X tried to import _protocols on line 25. So if you find a file that says something like "import _protocols" or "from _protocols import *" on line 25, then that might be the file that's getting imported, and causing trouble.

    2 other things to check:
    - is there a __init__.py in xsx? If so, it would get imported too
    - are there any stale .pyc files that might be causing trouble?

    Other than that, you could try adding some debug printfs to epydoc to try to track down what's causing the trouble. Or if you could construct a minimal test case that you can put in a zipfile and send to me, I could take a look at it. (Obviously, if I just copy/paste the single file kili.py and run epydoc on it, I don't get the error that you're getting.)

     
  • bart skowron

    bart skowron - 2008-08-24

    Logged In: YES
    user_id=1877836
    Originator: YES

    there was a xsx/__init__.py
    ghah. thank you for a help!

     

Log in to post a comment.