cannot open resource
See original GitHub issueI try to use it on Mac OS and there is a problem with PIL I think:
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-148-0d09cb35794e> in <module>()
2 elements = wordcloud.fit_words(freq_dist.items()[:200], width=500, height=500, font_path='/Users/paul/Library/Fonts/Verdana.ttf')
3 # Draw the positioned words to a PNG file.
----> 4 wordcloud.draw(elements, 'tagcloud-%s.png' % hashtag, width=500, height=500)
/Library/Python/2.7/site-packages/wordcloud/__init__.pyc in draw(elements, file_name, font_path, width, height, scale, color_func)
145 draw = ImageDraw.Draw(img)
146 for (word, count), font_size, position, orientation in elements:
--> 147 font = ImageFont.truetype(font_path, font_size * scale)
148 transposed_font = ImageFont.TransposedFont(font,
149 orientation=orientation)
/Library/Python/2.7/site-packages/PIL/ImageFont.pyc in truetype(filename, size, index, encoding)
216 and "armn" (Apple Roman). See the FreeType documentation
217 for more information.
--> 218 :return: A font object.
219 :exception IOError: If the file could not be read.
220 """
/Library/Python/2.7/site-packages/PIL/ImageFont.pyc in __init__(self, file, size, index, encoding)
132 else:
133 self.font_bytes = font.read()
--> 134 self.font = core.getfont("", size, index, encoding, self.font_bytes)
135
136 def getname(self):
IOError: cannot open resource
Issue Analytics
- State:
- Created 9 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
ImageFont IO error: cannot open resource - Stack Overflow
ttf') works while ImageFont.truetype('Arial.ttf') throws a 'cannot open resource' error. Annoying change, but worked for me.
Read more >OSError: Cannot open resource when trying to use Imagefont ...
Hi there. I am having issues when trying to execute code which contains the following line: from PIL import Image, ImageDraw, ImageFont.
Read more >OSError: cannot open resource | Python PIL : r/learnpython
When I run the below code, the OSError: cannot open resource always show up, no matter if the font is in the same...
Read more >OSError: cannot open resource - Replit
OSError: cannot open resource. Hi all! I'm getting this error trace in m console whenever someone joins my server. Ignoring exception in on_member_join...
Read more >"OSError: cannot open resource" when trying to load more ...
It worked fine at the beginning. Then I tried to generate some more samples (>1k) and got "OSError: cannot open resource" every time....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On my windows 7 machine, specifying font_path=‘C:\Windows\Fonts\msyh.ttf’ works well. I am generating word cloud for Chinese characters. FYI.
Thanks @flipdazed, thats it!