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

Import Error if module is not defined in this environment #8

Closed
pyatil opened this issue May 7, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@pyatil
Copy link

commented May 7, 2014

test.py:

import fooooooo

Traceback (most recent call last):
File "C:\Python27\Scripts\pdoc", line 454, in
module = imp.load_source('pdoc_file_module', fp, f)
File "User\work\test.py", line 17, in
import bdf
ImportError: No module named fooooooo

My project works in an environment who constructs python module dynamically. I can't use pdoc in this environment. How can I ignore this module and continue generate docs?

Thx for the help.

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented May 10, 2014

pdoc generates documentation by importing the module it is trying to document. This means that it must be a valid Python file that is importable in the current environment.

There are no plans to change this. (It would require parsing the Python AST manually.)

@BurntSushi BurntSushi closed this May 10, 2014

@ryneeverett

This comment has been minimized.

Copy link

commented Oct 20, 2015

There are no plans to change this. (It would require parsing the Python AST manually.)

Perhaps that would be prohibitively difficult but it seems like the tool would be a lot more robust if you didn't have to worry about import side-effects. For instance any django project would currently have to write a wrapper script to handle DJANGO_SETTINGS_MODULE.

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

@ryneeverett No, really, it's a non-starter. I totally agree that what you're describing would be awesome, but it would literally require a ground up rewrite. This means pdoc is not the project for that. It should be a new project.

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

@ryneeverett It's also probably one or two orders of magnitude harder to do.

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Oct 20, 2015

@ryneeverett On top of all of that, it's really hard (for me personally) to justify that kind of effort to work around non-idiomatic Python code (which shouldn't have nasty import side effects).

@TheCherry

This comment has been minimized.

Copy link

commented Nov 20, 2015

Have at the moment the same problem.
Did write a large application, that application use the vbox api.
There is at the moment no way to document my software, course he tell me every time:
Exception ImportError: 'No module named xpcom' in <bound method VirtualBoxManager.__del__ of <vboxapi.VirtualBoxManager object at 0x7fd3266d1b10>> ignored
I see noway to ignore that import and create a documentation, that is required for our customer.
Pydoc have exactly the same problem ...

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.