moymix / TaskMatrix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: partially initialized module 'charset_normalizer' has no attribute 'md__mypyc' (most likely due to a circular import)

niuwa2333 opened this issue · comments

Traceback (most recent call last):
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 70, in
import cchardet as chardet
ModuleNotFoundError: No module named 'cchardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "visual_chatgpt.py", line 2, in
import gradio as gr
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/gradio/init.py", line 3, in
import gradio.components as components
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/gradio/components.py", line 32, in
from gradio import media_data, processing_utils, utils
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/gradio/processing_utils.py", line 25, in
from gradio import encryptor, utils
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/gradio/utils.py", line 39, in
import aiohttp
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/aiohttp/init.py", line 6, in
from .client import (
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/aiohttp/client.py", line 59, in
from .client_reqrep import (
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 72, in
import charset_normalizer as chardet # type: ignore[no-redef]
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/charset_normalizer/init.py", line 23, in
from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
File "/data/ynj/conda_envs/visgpt/lib/python3.8/site-packages/charset_normalizer/api.py", line 10, in
from charset_normalizer.md import mess_ratio
AttributeError: partially initialized module 'charset_normalizer' has no attribute 'md__mypyc' (most likely due to a circular import)

Updating the charset-normalizer to latest version works for me:

pip install --force-reinstall charset-normalizer==3.1.0

as the solution suggested here https://stackoverflow.com/questions/75501048/how-to-fix-attributeerror-partially-initialized-module-charset-normalizer-has

Updating to latest version worked for me as well. Thanks @Elon-Chan !

Updating to latest version worked for me as well. Thanks @Elon-Chan !

commented

Elon-Chan Thanks works like charm.

**pip install --force-reinstall charset-normalizer==3.1.0**

However just a note, even though it correctly re-installs, receive an error in terminal and
an additional warning when jupyter notebook is restarted.

$ **pip install --force-reinstall charset-normalizer==3.1.0**
Collecting charset-normalizer==3.1.0
  Using cached charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
Installing collected packages: charset-normalizer
  Attempting uninstall: charset-normalizer
    Found existing installation: charset-normalizer 2.0.4
    Uninstalling charset-normalizer-2.0.4:
      Successfully uninstalled charset-normalizer-2.0.4
_ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
requests 2.28.1 requires charset-normalizer<3,>=2, but you have charset-normalizer 3.1.0 which is incompatible._
**Successfully installed charset-normalizer-3.1.0**

This solution:

pip install --force-reinstall charset-normalizer==3.1.0

Does not work for me.
Anyone else is stuck with this?

It is required by "requests" package which is at the core of most packages I use.

Updating to latest version worked for me, too. Thanks.

pip install --force-reinstall charset-normalizer==3.1.0