What is cannot import name 'py3', py3?

is working on a py file for cloud word images.
an error occurred while importing matplotlib.
error message

== RESTART: C:\Users\Administrator\Anaconda3\Lib\site-packages\WordCloud.py ==
Traceback (most recent call last):
  File "C:\Users\Administrator\Anaconda3\Lib\site-packages\WordCloud.py", line 3, in <module>
    from wordcloud import *
  File "C:\Users\Administrator\Anaconda3\Lib\site-packages\wordcloud\__init__.py", line 1, in <module>
    from .wordcloud import (WordCloud, STOPWORDS, random_color_func,
  File "C:\Users\Administrator\Anaconda3\Lib\site-packages\wordcloud\wordcloud.py", line 19, in <module>
    from PIL import Image
  File "C:\Users\Administrator\Anaconda3\Lib\site-packages\PIL\Image.py", line 31, in <module>
from ._util import py3
ImportError: cannot import name "py3"

is this the problem with matplotlib? Ask God for advice, thank you!

Jun.14,2022

is not a problem with matplotlib

if it is not the computer stutter , it is likely that the _ util.py file in the PIL folder is corrupted. It is recommended to reinstall PIL (python2) or pillow (python3)
I'll give you an example. My version is Python3.6.8 , which teaches you the method of human flesh debug.

according to this sentence:

  File "C:\Users\Administrator\Anaconda3\Lib\site-packages\PIL\Image.py", line 31, in <module>

I open Image.py this file
clipboard.png

py3:

:
clipboard.png
:
clipboard.png

, , , ,

:


_util.py

, py3:

clipboard.png
:
pythonpython3True, python2False
So

python, python3, Image.pyfrom ._util import py3

clipboard.png
py3 in this place, change directly to True
because you don't have to import _ util.py (if it was the same error just now), it should work.

if your version is Python2 , the operation is more or less the same, but there is also a pillow version problem you should pay attention to!

Menu