Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import modules/classes from other pacakges #74

Open
gvvka0327 opened this issue Nov 6, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@gvvka0327
Copy link

commented Nov 6, 2015

My package structure looks like below,

  system_test/
        /lib
          __init__.py
           module1.py
       /tests/
          __init__.py
          /category1
          __init__.py
             test1.py

test1.py imports module1.RestAPI class from /lib package

I was trying to generate pdoc documentation for test1.py, command I am using below,

pdoc --html --all-submodules --overwrite test1.py

I am getting this error below,

-bash-4.1$ pdoc --html --all-submodules --overwrite test1.py
Traceback (most recent call last):
  File "/usr/bin/pdoc", line 5, in <module>
    pkg_resources.run_script('pdoc==0.3.1', 'pdoc')
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 534, in run_script
    dist = self.by_key.get(req.key)
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 1434, in run_script
    def _listdir(self,fspath):
  File "/usr/lib/python2.6/site-packages/pdoc-0.3.1-py2.6.egg/EGG-INFO/scripts/pdoc", line 458, in <module>
    module = imp.load_source('__pdoc_file_module__', fp, f)

    from lib.module1 import RestAPI
ImportError: No module named lib.module1

Anyone else facing this issue, is there a work-around or is it needs to be fixed in the code?

Thank you

@gvvka0327

This comment has been minimized.

Copy link
Author

commented Nov 6, 2015

Few other people having similar issue,
http://stackoverflow.com/questions/31017196/pdoc-no-module-named-xxx
http://stackoverflow.com/questions/33517072/pdoc-cant-import-the-function-from-other-module
#65

I tried putting all = [] into init.py to make the modules public... did'nt solve the issue
did'nt try PYTHONPATH

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Nov 10, 2015

Please provide code that reproduces the issue. If I can't reproduce it, then I don't know how to fix it.

@devoxel

This comment has been minimized.

Copy link

commented Nov 10, 2015

@devoxel

This comment has been minimized.

Copy link

commented Nov 13, 2015

My colleague found a workaround.

Import the file from a file and run pdoc.html( 'module_name' ), where module name is the module you imported.

See the most recent commit here:

https://github.com/devoxel/repro-pdoc-behaviour

@tlescoat

This comment has been minimized.

Copy link

commented Dec 22, 2015

Sorry to bump this issue, but the fix mentioned in the stack overflow question is horrible. I think I may have found the solution in this issue: #83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.