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

Closed
gvvka0327 opened this issue Nov 6, 2015 · 6 comments
Closed

Unable to import modules/classes from other pacakges #74

gvvka0327 opened this issue Nov 6, 2015 · 6 comments

Comments

@gvvka0327
Copy link

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
Copy link
Author

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
Copy link
Contributor

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

@devoxel
Copy link

devoxel commented Nov 10, 2015

@devoxel
Copy link

devoxel 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
Copy link

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

@mhils
Copy link
Member

mhils commented Jan 19, 2021

The recommended way to document packages is to make them installable and the specify the module. In other words, don't specify mypackage/test.py, but install you package in a virtualenv and use mypackage.test.

@mhils mhils closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants