question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot open resource

See original GitHub issue

I 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:closed
  • Created 9 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ttang235commented, Mar 18, 2015

On my windows 7 machine, specifying font_path=‘C:\Windows\Fonts\msyh.ttf’ works well. I am generating word cloud for Chinese characters. FYI.

0reactions
balzer82commented, Dec 12, 2014

Thanks @flipdazed, thats it!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found