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

Exception on loading code: ImportError: cannot import name 'document' from 'megaparse_sdk.schema' #235

Open
bryanhughes opened this issue Feb 18, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@bryanhughes
Copy link

I upgraded Megaparse which succeeded and now I am getting the following exception on initialization.

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/bryan/dev/git/vialab/backend/janet/discovery/discover.py", line 16, in <module>
    from janet.tools import parse
  File "/Users/bryan/dev/git/vialab/backend/janet/tools/parse.py", line 6, in <module>
    from megaparse import MegaParse
  File "/Users/bryan/dev/git/vialab/backend/venv/lib/python3.11/site-packages/megaparse/__init__.py", line 1, in <module>
    from .megaparse import MegaParse
  File "/Users/bryan/dev/git/vialab/backend/venv/lib/python3.11/site-packages/megaparse/megaparse.py", line 7, in <module>
    from megaparse_sdk.schema import document
ImportError: cannot import name 'document' from 'megaparse_sdk.schema' (/Users/bryan/dev/git/vialab/backend/venv/lib/python3.11/site-packages/megaparse_sdk/schema/__init__.py)
python-BaseException
Copy link

dosubot bot commented Feb 18, 2025

Hey @bryanhughes! I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together!

The ImportError you're encountering suggests that the document component might not be directly importable from megaparse_sdk.schema. However, the Document class is still part of the megaparse_sdk.schema module, as it is defined in the document.py file within that module [1].

To resolve this issue, you can try importing the Document class directly from megaparse_sdk.schema.document instead of megaparse_sdk.schema. Here's how you can modify your import statement:

from megaparse_sdk.schema.document import Document

This should help you access the Document class without encountering the import error.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added the bug Something isn't working label Feb 18, 2025
@telboth
Copy link

telboth commented Feb 21, 2025

Hi, I had the same problem on my windows machine. I did a pip uninstall megaparse-sdk and then a pip install megaparse-sdk.
This upgraded megaparse-sdk from 0.1.10 to 0.1.12, and the problem went away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants