ImportError: cannot import name '_priv_parser', circular dependency

36 Views Asked by At

I struggled with this error on Pycharm, I'm using the BotCity framework and it wasn't barely starting running the script process when the following error was given:

> 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 "D:\path\padroniza_estilo_planilha.py", line 10, in <module>
>     from botcity.document_processing import *
File   "C:\Users\Usuario\AppData\Local\Programs\Python\Python311\Lib\site-packages\botcity\document_processing\__init__.py",
> line 1, in <module>
>     from .parser import Entry, DocumentParser  # noqa: F401, F403
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "C:\Users\Usuario\AppData\Local\Programs\Python\Python311\Lib\site-packages\botcity\document_processing\parser\__init__.py",
> line 1, in <module>
>     from .document import DocumentParser  # noqa: F401, F403
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "C:\Users\Usuario\AppData\Local\Programs\Python\Python311\Lib\site-packages\botcity\document_processing\parser\document.py",
> line 4, in <module>`
>     from . import _priv_parser
> 
> ImportError: cannot import name '_priv_parser' from partially initialized module`'botcity.document_processing.parser'
> (most likely due to a circular import)
> (C:\Users\Usuario\AppData\Local\Programs\Python\Python311\Lib\site-packages\botcity\document_processing\parser\__init__.py)

I've tried everything, mostly pip install botcity-documents and pip install --upgrade botcity-documents and it wasn't working well even tho apperently it should, since the "Successfully installed" message was given at the end of the installing.

1

There are 1 best solutions below

2
RafaWiz On

The clue is disabling the antivirus (I assumed the risk). At the time of installation (pip install) the antivirus was indentifying the create file _priv_parser.py as a threat and moving it to quarentine, so when running the script the error was immediately thrown because the file wasn't finded/existed which at the end of it all resulted in circular dependencies between two other files (belonging to the same directory document_processing) of the process.