deepset-ai / haystack

:mag: AI orchestration framework to build customizable, production-ready LLM applications. Connect components (models, vector DBs, file converters) to pipelines or agents that can interact with your data. With advanced retrieval methods, it's best suited for building RAG, question answering, semantic search or conversational agent chatbots.
https://haystack.deepset.ai
Apache License 2.0
17.62k stars 1.91k forks source link

No module named 'haystack.utils.import_utils' #3188

Closed carolzbnbr closed 2 years ago

carolzbnbr commented 2 years ago

Describe the bug Getting error ModuleNotFoundError: No module named 'haystack.utils.import_utils'; 'haystack.utils' is not a package when importing EmbeddingRetriever from haystack.nodes import EmbeddingRetriever

Error message ModuleNotFoundError: No module named 'haystack.utils.import_utils'; 'haystack.utils' is not a package

full error message/trace Traceback (most recent call last): File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/web/teste.py", line 1, in <module> from haystack.nodes import EmbeddingRetriever File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/haystack/haystack/nodes/__init__.py", line 1, in <module> from haystack.utils.import_utils import safe_import ModuleNotFoundError: No module named 'haystack.utils.import_utils'; 'haystack.utils' is not a package

Expected behavior Run script without errors

Additional context I already attempted to execute basic installation, or full installation (using '.[all]' argument), the installation works like a charm, but when I run the script, I got the mentioned error.

To Reproduce 1 - Create a new .py file 2 - Add from haystack.nodes import EmbeddingRetriever 4 - Save and run

FAQ Check

System:

Side note: Attempted to execute on python 3.10 and 3.9

masci commented 2 years ago

Hi @carolzbnbr and thanks for the detailed report!

I have the same system as yours but wasn't able to reproduce. I tried with a virtualenv (I am manually activating it here to avoid confusion but I usually have a project manger tool):

~ python -m venv ./myvenv
~ export PATH=$PWD/myvenv/bin:$PATH
~ which python                                            
/Users/massi/myvenv/bin/python
~ pip install farm-haystack
...
~ pip show farm-haystack
Name: farm-haystack
Version: 1.8.0
~ python -c"from haystack.nodes import EmbeddingRetriever"
~

Can you try the above steps and let me know the output?

carolzbnbr commented 2 years ago

Hello @masci,

Thanks for helping me.

Here is the output I got by running python -c"from haystack.nodes import EmbeddingRetriever":

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/nodes/__init__.py", line 1, in <module>
    from haystack.utils.import_utils import safe_import
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/utils/__init__.py", line 2, in <module>
    from haystack.utils.preprocessing import convert_files_to_docs, tika_convert_files_to_docs
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/utils/preprocessing.py", line 7, in <module>
    from haystack.nodes.file_converter import BaseConverter, DocxToTextConverter, PDFToTextConverter, TextConverter
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/nodes/file_converter/__init__.py", line 1, in <module>
    from haystack.nodes.file_converter.base import BaseConverter
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/nodes/file_converter/base.py", line 7, in <module>
    from haystack.nodes.base import BaseComponent
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/nodes/base.py", line 11, in <module>
    from haystack.errors import PipelineSchemaError
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/errors.py", line 5, in <module>
    from haystack.telemetry import send_custom_event
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/telemetry.py", line 20, in <module>
    from haystack.environment import HAYSTACK_EXECUTION_CONTEXT, get_or_create_env_meta_data
  File "/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/environment.py", line 8, in <module>
    from haystack import __version__
ImportError: cannot import name '__version__' from 'haystack' (/Users/carolinazambon/Projects/ArcTouch.AI.Search/src/python/myvenv/lib/python3.9/site-packages/haystack/__init__.py)
carolzbnbr commented 2 years ago

I tried again, I don't know why, but everything seems fine now.

Thanks!

masci commented 2 years ago

@carolzbnbr happy you solved the issue, let us know should you have more questions!

snowsky commented 1 year ago

Run into the same error with conda but worked with venv