-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Runtime detection for default backend #3679
Comments
This ties in with a request from the Ipython people to auto detect if you are in a note book and launch nbagg/inline. |
I think this is relevant request. It is complicated by two issues as far as I can see.
|
Yeah -- I think historically the main driver against doing this was the performance/clumsiness of trying to import a bunch of different guis at start up. At the very best, you have the overhead of importing the first gui to try in a separate process, because if that fails, you can't then load another gui in the same process later and expect it to work. And that turns out to be a lot of overhead. So, unless we can find a way around that -- i.e. a "cheaper" way to detect the installation of GUI frameworks that works across all of our platforms (i.e. there's distro-specific tricks that could be used, but that's going to be a lot of work to maintain all of the combinations), I'm not sure this is doable. |
What about just on the first startup? . |
First startup is an interesting idea. We could move the logic we already have during compilation to something that runs, in a child process, on first startup and then saves the result in a config file. Lots of tricky details there, but it might help this use case. |
Down side of first start up is that it can mess with people who bounce between backends ex going from running ipython in the terminal to running a notebook. I don't think we can assume that user is always going to want to use mpl the same way as the first time they import pyplot. |
For detecting if a GUI library is installed, how about just assuming the toolkit is installed correctly if the module is present? We can detect if a module is present by using the "imp" module without actually import the module, this way we should have a much less overhead for big players like Qt and GTK. Just an example:
|
@felixonmars: That last idea could work -- and we could easily detect the IPython notebook in there, too. Are you interested in working that into a pull request? This is the kind of thing that will require a lot of hammering on in various environments and configurations to get all the details right -- having a PR will give us a chance to try it out many places. |
Possibly related... I think it might be useful to emit some kind of warning On Tue, Oct 21, 2014 at 7:59 AM, Michael Droettboom <
|
@WeatherGod, then if someone develops a script that saves a figure and uses show() for testing and local use, and wants to use the same script on a cloud server, it would generate a warning. Is this a good tradeoff? |
@mdboom I'd like to, but I may have to take a look into the current code first as I'm not familiar with it yet 😄 |
fantastic question. I usually protect my plt.show() with an if-statement On Wed, Oct 22, 2014 at 3:25 AM, Eric Firing notifications@github.com
|
I believe this continues to stand as a valid request - please read the thread for some useful discussion |
xref #8613 (comment) |
This is implemented as of 3.0 (#9795 and following PRs). |
While I'd like to make every backend available for a distribution package, the Qt5Agg backend will be set as default by matplotlib's installation script, and when a user doesn't have qt5 installed, matplotlib will throw an error if the client application didn't specify a backend.
It would be nice if there could be a fallback logic on runtime so the best-available GUI backend will be chosen as the default backend.
The text was updated successfully, but these errors were encountered: