Please fix pip install, so that etc works correctly

Please fix pip install, so that 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])

What I expect to happen: plot should show

What actually happens: nothing

Other people with similar issue: see this stackoverflow question:

Author: Fantashit

1 thought on “Please fix pip install, so that etc works correctly

  1. 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

    On Sun, Dec 14, 2014 at 8:13 AM, Hugh Perkins

    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
    Date:14/12/2014 9:05 PM (GMT+08:00)
    To: matplotlib/matplotlib
    Cc: Hugh Perkins
    Subject: Re: [matplotlib] Please fix pip install, so that 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)

Comments are closed.