YouTube-Report icon indicating copy to clipboard operation
YouTube-Report copied to clipboard

wordcloud problems (python3.7)

Open Flewrider opened this issue 5 years ago • 8 comments
trafficstars

Running the script only works with 3.7 for me and generates the following error after installing all dependencies for the correct version with "python3.7 -m pip install -r requirements.txt":

Generating Word Cloud.....
Traceback (most recent call last):
  File "report.py", line 234, in <module>
    visual.wordCloud()
  File "report.py", line 83, in wordCloud
    max_words=380,contour_width=2, prefer_horizontal=1).generate(unique_string)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 619, in generate
    return self.generate_from_text(text)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 601, in generate_from_text
    self.generate_from_frequencies(words)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 434, in generate_from_frequencies
    max_font_size=self.height)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 483, in generate_from_frequencies
    font = ImageFont.truetype(self.font_path, font_size)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 640, in truetype
    return freetype(font)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 637, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 186, in __init__
    font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "report.py", line 234, in <module>
    visual.wordCloud()
  File "report.py", line 83, in wordCloud
    max_words=380,contour_width=2, prefer_horizontal=1).generate(unique_string)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 619, in generate
    return self.generate_from_text(text)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 601, in generate_from_text
    self.generate_from_frequencies(words)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 434, in generate_from_frequencies
    max_font_size=self.height)
  File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 483, in generate_from_frequencies
    font = ImageFont.truetype(self.font_path, font_size)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 640, in truetype
    return freetype(font)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 637, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 186, in __init__
    font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource

Flewrider avatar Dec 14 '19 16:12 Flewrider

Enclose multi-line code blocks with 3 backticks to format it, like this: ``` multi line code ```

arpreq avatar Dec 14 '19 16:12 arpreq

Looks more like a problem related to the differences between linux and windows, but I'll have to investigate further to confirm that assumption.

RiedleroD avatar Dec 14 '19 23:12 RiedleroD

Traceback (most recent call last): File "report.py", line 234, in visual.wordCloud() File "report.py", line 83, in wordCloud max_words=380,contour_width=2, prefer_horizontal=1).generate(unique_string) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 619, in generate return self.generate_from_text(text) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 601, in generate_from_text self.generate_from_frequencies(words) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 434, in generate_from_frequencies max_font_size=self.height) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 483, in generate_from_frequencies font = ImageFont.truetype(self.font_path, font_size) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 640, in truetype return freetype(font) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 637, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 186, in init font, size, index, encoding, layout_engine=layout_engine OSError: cannot open resource Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in import apt File "/usr/lib/python3/dist-packages/apt/init.py", line 23, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'

Original exception was: Traceback (most recent call last): File "report.py", line 234, in visual.wordCloud() File "report.py", line 83, in wordCloud max_words=380,contour_width=2, prefer_horizontal=1).generate(unique_string) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 619, in generate return self.generate_from_text(text) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 601, in generate_from_text self.generate_from_frequencies(words) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 434, in generate_from_frequencies max_font_size=self.height) File "/home/flew/.local/lib/python3.7/site-packages/wordcloud/wordcloud.py", line 483, in generate_from_frequencies font = ImageFont.truetype(self.font_path, font_size) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 640, in truetype return freetype(font) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 637, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/flew/.local/lib/python3.7/site-packages/PIL/ImageFont.py", line 186, in init font, size, index, encoding, layout_engine=layout_engine OSError: cannot open resource

rogeliomartinez0505 avatar Dec 26 '19 20:12 rogeliomartinez0505

Getting the same error, except without the 'apt_pkg' part. STDOUT and STDERR: https://paste.rs/MGB

Running on Arch Linux with Python 3.8.

selplacei avatar Jan 18 '20 23:01 selplacei

Can you test if you get the same error when using my fork? Please open a separate issue there if there's still something wrong. Unlike other people, I'll actually fix the problem if there is one.

RiedleroD avatar Jan 21 '20 07:01 RiedleroD

Can you test if you get the same error when using my fork? Please open a separate issue there if there's still something wrong. Unlike other people, I'll actually fix the problem if there is one.

Your issues are closed, but I tried it out anyway. The bug is still exactly the same.

selplacei avatar Jan 22 '20 00:01 selplacei

I don't know why the issues were closed, they should be there now. I also hopefully fixed the OSError that gets raised in your case. Can you please confirm that?

RiedleroD avatar Jan 26 '20 11:01 RiedleroD

The OSError is fixed, but I got a completely different error. See the fork for the issue.

selplacei avatar Jan 27 '20 01:01 selplacei