Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import hangs when importing pyplot #2919

Closed
notmatthancock opened this issue Mar 23, 2014 · 10 comments
Closed

Import hangs when importing pyplot #2919

notmatthancock opened this issue Mar 23, 2014 · 10 comments

Comments

@notmatthancock
Copy link
Contributor

This is another font issue. This is similar to this one, although the solution found there doesn't work for me. I am on OSX 10.6 using python 2.7.6. I installed the latest via git. That went fine. I can import matplotlib:

import matplotlib
print matplotlib.__version__
=> 1.4.x

Now if I do:

import matplotlib.pyplot

I get nothing. It just hangs. This is the traceback which is what leads me to believe that this a font manager issue: https://gist.github.com/chestervonwinchester/9725539

@notmatthancock
Copy link
Contributor Author

I found some related issues. It turns out my fontCache got deleted from the ~/.matplotlib/ directory. Where the import was appearing to stall, was just the fc-list call be executed. This call took about 10 or 15 minutes to execute, but now that the cache is built, everything is dandy.

@WeatherGod
Copy link
Member

10 to 15 minutes?!

The most I have ever seen was 2 minutes. Maybe we need to do something to
at least output a message (via logging, of course) to give a user a heads
up on what might be happening. Another thing to look into is to see how we
could constrain the fc-list call to keep it from taking a ridiculous amount
of time.

On Tue, Mar 25, 2014 at 12:06 PM, chestervonwinchester <
notifications@github.com> wrote:

Closed #2919 #2919.

Reply to this email directly or view it on GitHubhttps://github.com//issues/2919
.

@mdboom
Copy link
Member

mdboom commented Mar 25, 2014

How many fonts to you have installed on your system? Are any on slow media, such as network drives? 10-15 minutes seems way out of line. fc-list takes 0.022 seconds on my system.

@notmatthancock
Copy link
Contributor Author

Ok I apologize. My impatience is warping my perception of time because:

$ time fc-list
....font lists...
real    1m44.781s
user    0m59.607s
sys 0m23.015s

In any case, I think you're right about an output message because this could've been resolved by simply letting the thing run. Instead, I assumed there was an error, and continued aborting and hunting tracebacks. Perhaps if there was a check to see if the matplotlib fontCache exists and if not, prompt a message.

I have ~2461 fonts and no slow media.

@ialexryan
Copy link

Why is this closed? Even if the solution is as simple as running fc-list, there should be some sort of error instead of just hanging forever.

@jenshnielsen
Copy link
Member

Because that is not the solution. What happens is that matplotlib calls fc-list on the first import of pyplot to create the font cache. Unfortunately this can be really slow on some systems but it's not really an issue in matplotlib. No where in this issue is there any indication of anything hanging forever. It will hang for the time it takes to execute fc-list only.

@ialexryan
Copy link

Sorry, I meant forever in the colloquial sense. Most users have been trained by convention to expect that any program that produces no visual output for more than several seconds without warning has crashed - I know I have. Could we at least print a line saying something like "Running fc-list. This may take up to several minutes." ?

@RichardoC
Copy link

I'm also suffering from a slow fc-list import. A warning in the console would be appreciated. The only reason I spotted that the kernel wasn't hung was due to htop.

@jenshnielsen
Copy link
Member

@RichardoC there already is a warning at import time in 1.5.1 see #5640 also see #5836 for users whishing to remove it again. Are you using an older version of matplotlib?

@RichardoC
Copy link

Just updated and the warning is now showing up. It's a nice feature to have.

Ivan1248 added a commit to Ivan1248/vidlu that referenced this issue Jul 11, 2021
for cases when matplotlib.pyplot takes long to load.
For more information, see matplotlib/matplotlib#2919
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants