Scrapegraph-ai icon indicating copy to clipboard operation
Scrapegraph-ai copied to clipboard

ModuleNotFoundError: No module named 'scrapegraphai.graphs'; 'scrapegraphai' is not a package

Open Bandit253 opened this issue 9 months ago • 6 comments

I have pip installed with no error reported. in both virtual and source environments.

When I try to run if fails...

Exception has occurred: ModuleNotFoundError
No module named 'scrapegraphai.graphs'; 'scrapegraphai' is not a package
AttributeError: partially initialized module 'scrapegraphai' has no attribute '__path__' (most likely due to a circular import)

During handling of the above exception, another exception occurred:

  File "D:\_SimpleMovie\scrapegraphai.py", line 2, in <module>
    from scrapegraphai.graphs import SmartScraperGraph
  File "D:\_SimpleMovie\scrapegraphai.py", line 2, in <module>
    from scrapegraphai.graphs import SmartScraperGraph
ModuleNotFoundError: No module named 'scrapegraphai.graphs'; 'scrapegraphai' is not a package

Desktop (please complete the following information):

  • OS: Win 11
  • python 3.11.4

Bandit253 avatar May 10 '24 23:05 Bandit253

Hey @Bandit253 can you try re-installing it now in a new virtual environment?

PeriniM avatar May 11 '24 08:05 PeriniM

We made an update

VinciGit00 avatar May 11 '24 08:05 VinciGit00

Sorry, no luck :(

First I tried Upgrade, same then I tried uninstall, and re-install, result consistent... below

Successfully installed scrapegraphai-0.10.1

D:\_SimpleMovie>.env311\Scripts\python.exe
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from scrapegraphai.graphs import SmartScraperGraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\scrapegraphai.py", line 2, in <module>
    from scrapegraphai.graphs import SmartScraperGraph
ModuleNotFoundError: No module named 'scrapegraphai.graphs'; 'scrapegraphai' is not a package

Why does it list a script name when I just used command prompt? with no reference to that file?

Bandit253 avatar May 11 '24 10:05 Bandit253

@Bandit253 if you have environment activated could you try after just using python command to start the interpreter. Invoking the python.exe like above may cause issue such as above.

dimritium avatar May 11 '24 17:05 dimritium

@Bandit253 if you have environment activated could you try after just using python command to start the interpreter. Invoking the python.exe like above may cause issue such as above.

Yes, that appears to work, well at least no error on import. So:

  • fresh environment
  • Activated
  • Python.exe
  • Import works BUT;
  • not Activated it doesn't work,
  • just using new env python.exe doesn't

How can this be? Before I forget, thanks for the help!

Bandit253 avatar May 11 '24 22:05 Bandit253

Update on last.

"... at least no error on import." was completely correct when I tried to run the script, in activated env, same import error :(

(.SCRAPE) D:\>python _SimpleMovie\scrapegraphai.py
Traceback (most recent call last):
  File "D:\_SimpleMovie\scrapegraphai.py", line 2, in <module>
    from scrapegraphai.graphs import SmartScraperGraph
  File "D:\_SimpleMovie\scrapegraphai.py", line 2, in <module>
    from scrapegraphai.graphs import SmartScraperGraph
ModuleNotFoundError: No module named 'scrapegraphai.graphs'; 'scrapegraphai' is not a package

Bandit253 avatar May 11 '24 22:05 Bandit253

scrapegraphai.py

the issue is how Module Import works in Python:) Please try changing the name of your file scrapegraphai.py, since third-party module name is same.

dimritium avatar May 12 '24 06:05 dimritium

Lol

VinciGit00 avatar May 12 '24 06:05 VinciGit00

scrapegraphai.py

the issue is how Module Import works in Python:) Please try changing the name of your file scrapegraphai.py, since third-party module name is same.

Yeah that makes sense, NOW, well spotted!! Thank you all

Bandit253 avatar May 12 '24 10:05 Bandit253