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

Please fix pip install, so that plt.show() etc works correctly #3920

Closed
hughperkins opened this issue Dec 14, 2014 · 9 comments
Closed

Please fix pip install, so that plt.show() etc works correctly #3920

hughperkins opened this issue Dec 14, 2014 · 9 comments

Comments

@hughperkins
Copy link

Please fix pip install, so that plt.show() etc work correctly.

What I do:

  • on ubuntu 14.04
  • virtualenv ~/env
  • source ~/env/bin/activate
  • pip install numpy
  • pip install matplotlib
  • python
  • import matplotlib.pyplot as plt
  • plt.scatter([3,2,5],[3,4,2])
  • plt.show()

What I expect to happen: plot should show

What actually happens: nothing

Other people with similar issue: see this stackoverflow question: http://stackoverflow.com/questions/7534453/matplotlib-does-not-show-my-drawings-although-i-call-pyplot-show

@tacaswell
Copy link
Member

I suspect the problem is that the venv is hiding the optional dependencies related to the gui frameworks. If that is the case I think that the install script is working correctly as the gui frameworks are optional.

@hughperkins
Copy link
Author

Ok. How to fix the install in my virtualenv? What is the exact sequence of commands i should type? 

-------- Original message --------
From: Thomas A Caswell notifications@github.com
Date:14/12/2014 9:05 PM (GMT+08:00)
To: matplotlib/matplotlib matplotlib@noreply.github.com
Cc: Hugh Perkins hughperkins@gmail.com
Subject: Re: [matplotlib] Please fix pip install, so that plt.show() etc works
correctly (#3920)

I suspect the problem is that the venv is hiding the optional dependencies related to the gui frameworks. If that is the case I think that the install script is working correctly as the gui frameworks are optional.


Reply to this email directly or view it on GitHub.

@WeatherGod
Copy link
Member

pip is working fine, it is a problem with virtualenv (sort of). By default,
the venv you create can not see the site-packages from the python install
that it copies from. Most likely, you would already have on your linux
system either PyQt or GTK installed to the system's site-packages. Thus,
when you install matplotlib via pip outside the venv, everything works fine
because those packages can be found by the system python when matplotlib is
built. But in the venv, they can't be found and so the matplotlib build
falls back to the headless state.

One way to mitigate this is to install the tkinter headers on your system.
Your venv will have access to the tkinter packages (it gets copied over
when the virtual environment gets built) and the tk headers would then be
available globally, regardless of whether you are in the system python or
the venv. Then, when matplotlib is built, it will find tk headers and build
the tkagg backend. The tkagg and macosx backends (and technically, the
lesser known "windowing" backend) are the only backends that need to be
compiled before it can be used.

As a side note, this problem only exists for Linux. pip will install
matplotlib using wheels for Windows and Macs, which would already have the
backends compiled, or would have one of the optional toolkits be a required
dependency.

On Sun, Dec 14, 2014 at 8:13 AM, Hugh Perkins notifications@github.com
wrote:

Ok. How to fix the install in my virtualenv? What is the exact sequence of
commands i should type?

-------- Original message --------
From: Thomas A Caswell notifications@github.com
Date:14/12/2014 9:05 PM (GMT+08:00)
To: matplotlib/matplotlib matplotlib@noreply.github.com
Cc: Hugh Perkins hughperkins@gmail.com
Subject: Re: [matplotlib] Please fix pip install, so that plt.show() etc
works correctly (#3920)

I suspect the problem is that the venv is hiding the optional dependencies
related to the gui frameworks. If that is the case I think that the install
script is working correctly as the gui frameworks are optional.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#3920 (comment)
.

@hughperkins
Copy link
Author

Hi, idea: please could you consider factorizing the pip install packages plausibly?

  • pip install matplotlib -> installs matplotlib, with no graphical dependencies
  • pip install matplotlib-gtk -> installs matplotlib, fails ideally, or at least presents a clear warning/error if appropriate gtk libraries not already installed

@hughperkins
Copy link
Author

(alternatively, at least please document clearly somewhere the exact packages we should ensure are installed into our virtualenv, so we can follow this. Note that matplotlib outside of a virtualenv works ok for me, but then it's a super old version of pandas etc, which is not really ideal.

  • for now, I've gone with first installing matplotlib globally, then creating a virtualenv with site-packages included, but it's not really ideal
    )

@white-gecko
Copy link

Which matplotlib packages do exist?

There doesn't seam to be any matplotlib-gtk:

$ pip install matplotlib-gtk
Downloading/unpacking matplotlib-gtk
  Could not find any downloads that satisfy the requirement matplotlib-gtk
Cleaning up...
No distributions at all found for matplotlib-gtk

@tacaswell
Copy link
Member

If you would like to do that re factoring we will be happy to incorporate
it.

http://matplotlib.org/users/installing.html#optional-gui-framework gives
the requirements for having access to the gui backends.

An easier solution to the venv issue is too soft link in the frame work
related packages or allow global packages before trying to install mpl.

I would also look at anaconda.

On Thu, Dec 18, 2014, 15:34 Natanael Arndt notifications@github.com wrote:

Which matplotlib packages do exist?


Reply to this email directly or view it on GitHub
#3920 (comment)
.

@WeatherGod
Copy link
Member

The other approach is to use the "provides" expression syntax. If we
designate the various optional backends as "provides", then I think there
is a way to then easily specify that to pip. I am not familiar with it,
though.

On Thu, Dec 18, 2014 at 6:47 PM, Thomas A Caswell notifications@github.com
wrote:

If you would like to do that re factoring we will be happy to incorporate
it.

http://matplotlib.org/users/installing.html#optional-gui-framework gives
the requirements for having access to the gui backends.

An easier solution to the venv issue is too soft link in the frame work
related packages or allow global packages before trying to install mpl.

I would also look at anaconda.

On Thu, Dec 18, 2014, 15:34 Natanael Arndt notifications@github.com
wrote:

Which matplotlib packages do exist?


Reply to this email directly or view it on GitHub
<
https://github.com/matplotlib/matplotlib/issues/3920#issuecomment-67576083>

.


Reply to this email directly or view it on GitHub
#3920 (comment)
.

@danielotieno
Copy link

@WeatherGod Thank you very much for your helpful comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants