Movatterモバイル変換


[0]ホーム

URL:


You are reading an old version of the documentation (v2.0.0). For the latest version seehttps://matplotlib.org/stable/
matplotlib

Navigation


Travis-CI:

Table Of Contents

Related Topics

This Page

Quick search

Working with Matplotlib in Virtual environments

Introduction

When runningmatplotlib in avirtual environment you may discovera few issues.matplotlib itself has no issue with virtual environments.However, the GUI frameworks thatmatplotlib uses for interactivefigures have some issues with virtual environments. Everything below assumessome familiarity with the Matplotlib backends as found inWhat is abackend?.

If you only use theIPython/JupyterNotebook‘sinline andnotebookbackends and non interactive backends you should not have any issues and canignore everything below.

If you are using Matplotlib on OSX you may also want to consider theOSX framework FAQ.

GUI Frameworks

Interactive Matplotlib relies heavily on the interaction with external GUIframeworks.

Most GUI frameworks are not pip installable. This makes it tricky to installthem within a virtual environment. This problem does not exist if you use Condaenvironments where you can install all Conda supported GUI frameworks directlyinto the environment. In regular virtualenv environment various workaroundsexist. Some of these are given here:

  • TheTKAgg backend doesn’t require any external dependencies and isnormally always available.
  • TheQT4 frameworkPySide is pip installable.
  • PYQT5 is pip installable on Python 3.5.

Other frameworks are harder to install into a virtual environment. There are atleast two possible ways to get access to these in a virtual environment.

One often suggested solution is to use the--system-site-packages optionto virtualenv when creating an environment. This adds all system wide packagesto the virtual environment. However, this breaks the isolation between thevirtual environment and the system install. Among other issues it results inhard to debug problems with system packages shadowing the environment packages.If you usevirtualenvwrapperthis can be toggled with thetoggleglobalsitepackages command.

Alternatively, you can manually symlink the GUI frameworks into the environment.I.e. to use PyQt5, you should symlinkPyQt5 andsip from your systemsite packages directory into the environment taking care that the environmentand the systemwide install use the same python version.

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2016 The Matplotlib development team. Last updated on Feb 20, 2017. Created usingSphinx 1.5.2.

[8]ページ先頭

©2009-2025 Movatter.jp