|
| 1 | +.. _troubleshooting-faq: |
| 2 | + |
| 3 | +.. redirect-from:: /faq/troubleshooting_faq |
| 4 | + |
| 5 | +*************** |
| 6 | +Troubleshooting |
| 7 | +*************** |
| 8 | + |
| 9 | +.. contents:: |
| 10 | + :backlinks: none |
| 11 | + |
| 12 | +.. _matplotlib-version: |
| 13 | + |
| 14 | +Obtaining Matplotlib version |
| 15 | +============================ |
| 16 | + |
| 17 | +To find out your Matplotlib version number, import it and print the |
| 18 | +``__version__`` attribute:: |
| 19 | + |
| 20 | + >>> import matplotlib |
| 21 | + >>> matplotlib.__version__ |
| 22 | + '0.98.0' |
| 23 | + |
| 24 | + |
| 25 | +.. _locating-matplotlib-install: |
| 26 | + |
| 27 | +:file:`matplotlib` install location |
| 28 | +=================================== |
| 29 | + |
| 30 | +You can find what directory Matplotlib is installed in by importing it |
| 31 | +and printing the ``__file__`` attribute:: |
| 32 | + |
| 33 | + >>> import matplotlib |
| 34 | + >>> matplotlib.__file__ |
| 35 | + '/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/__init__.pyc' |
| 36 | + |
| 37 | +.. _locating-matplotlib-config-dir: |
| 38 | + |
| 39 | +:file:`matplotlib` configuration and cache directory locations |
| 40 | +============================================================== |
| 41 | + |
| 42 | +Each user has a Matplotlib configuration directory which may contain a |
| 43 | +:ref:`matplotlibrc <customizing-with-matplotlibrc-files>` file. To |
| 44 | +locate your :file:`matplotlib/` configuration directory, use |
| 45 | +:func:`matplotlib.get_configdir`:: |
| 46 | + |
| 47 | + >>> import matplotlib as mpl |
| 48 | + >>> mpl.get_configdir() |
| 49 | + '/home/darren/.config/matplotlib' |
| 50 | + |
| 51 | +On Unix-like systems, this directory is generally located in your |
| 52 | +:envvar:`HOME` directory under the :file:`.config/` directory. |
| 53 | + |
| 54 | +In addition, users have a cache directory. On Unix-like systems, this is |
| 55 | +separate from the configuration directory by default. To locate your |
| 56 | +:file:`.cache/` directory, use :func:`matplotlib.get_cachedir`:: |
| 57 | + |
| 58 | + >>> import matplotlib as mpl |
| 59 | + >>> mpl.get_cachedir() |
| 60 | + '/home/darren/.cache/matplotlib' |
| 61 | + |
| 62 | +On Windows, both the config directory and the cache directory are |
| 63 | +the same and are in your :file:`Documents and Settings` or :file:`Users` |
| 64 | +directory by default:: |
| 65 | + |
| 66 | + >>> import matplotlib as mpl |
| 67 | + >>> mpl.get_configdir() |
| 68 | + 'C:\\Documents and Settings\\jdhunter\\.matplotlib' |
| 69 | + >>> mpl.get_cachedir() |
| 70 | + 'C:\\Documents and Settings\\jdhunter\\.matplotlib' |
| 71 | + |
| 72 | +If you would like to use a different configuration directory, you can |
| 73 | +do so by specifying the location in your :envvar:`MPLCONFIGDIR` |
| 74 | +environment variable -- see |
| 75 | +:ref:`setting-linux-osx-environment-variables`. Note that |
| 76 | +:envvar:`MPLCONFIGDIR` sets the location of both the configuration |
| 77 | +directory and the cache directory. |
| 78 | + |
| 79 | +.. _reporting-problems: |
| 80 | +.. _getting-help: |
| 81 | + |
| 82 | +Getting help |
| 83 | +============ |
| 84 | + |
| 85 | +There are a number of good resources for getting help with Matplotlib. |
| 86 | +There is a good chance your question has already been asked: |
| 87 | + |
| 88 | +- The `mailing list archive |
| 89 | + <https://discourse.matplotlib.org/c/community/matplotlib-users/6>`_. |
| 90 | + |
| 91 | +- `GitHub issues <https://github.com/matplotlib/matplotlib/issues>`_. |
| 92 | + |
| 93 | +- Stackoverflow questions tagged `matplotlib |
| 94 | + <https://stackoverflow.com/questions/tagged/matplotlib>`_. |
| 95 | + |
| 96 | +If you are unable to find an answer to your question through search, please |
| 97 | +provide the following information in your e-mail to the `mailing list |
| 98 | +<https://mail.python.org/mailman/listinfo/matplotlib-users>`_: |
| 99 | + |
| 100 | +* Your operating system (Linux/Unix users: post the output of ``uname -a``). |
| 101 | + |
| 102 | +* Matplotlib version:: |
| 103 | + |
| 104 | + python -c "import matplotlib; print(matplotlib.__version__)" |
| 105 | + |
| 106 | +* Where you obtained Matplotlib (e.g., your Linux distribution's packages, |
| 107 | + GitHub, PyPI, or `Anaconda <https://www.anaconda.com/>`_). |
| 108 | + |
| 109 | +* Any customizations to your ``matplotlibrc`` file (see |
| 110 | + :ref:`customizing`). |
| 111 | + |
| 112 | +* If the problem is reproducible, please try to provide a *minimal*, standalone |
| 113 | + Python script that demonstrates the problem. This is *the* critical step. |
| 114 | + If you can't post a piece of code that we can run and reproduce your error, |
| 115 | + the chances of getting help are significantly diminished. Very often, the |
| 116 | + mere act of trying to minimize your code to the smallest bit that produces |
| 117 | + the error will help you find a bug in *your* code that is causing the |
| 118 | + problem. |
| 119 | + |
| 120 | +* Matplotlib provides debugging information through the `logging` library, and |
| 121 | + a helper function to set the logging level: one can call :: |
| 122 | + |
| 123 | + plt.set_loglevel("info") # or "debug" for more info |
| 124 | + |
| 125 | + to obtain this debugging information. |
| 126 | + |
| 127 | + Standard functions from the `logging` module are also applicable; e.g. one |
| 128 | + could call ``logging.basicConfig(level="DEBUG")`` even before importing |
| 129 | + Matplotlib (this is in particular necessary to get the logging info emitted |
| 130 | + during Matplotlib's import), or attach a custom handler to the "matplotlib" |
| 131 | + logger. This may be useful if you use a custom logging configuration. |
| 132 | + |
| 133 | +If you compiled Matplotlib yourself, please also provide: |
| 134 | + |
| 135 | +* any changes you have made to ``setup.py`` or ``setupext.py``. |
| 136 | +* the output of:: |
| 137 | + |
| 138 | + rm -rf build |
| 139 | + python setup.py build |
| 140 | + |
| 141 | + The beginning of the build output contains lots of details about your |
| 142 | + platform that are useful for the Matplotlib developers to diagnose your |
| 143 | + problem. |
| 144 | + |
| 145 | +* your compiler version -- e.g., ``gcc --version``. |
| 146 | + |
| 147 | +Including this information in your first e-mail to the mailing list |
| 148 | +will save a lot of time. |
| 149 | + |
| 150 | +You will likely get a faster response writing to the mailing list than |
| 151 | +filing a bug in the bug tracker. Most developers check the bug |
| 152 | +tracker only periodically. If your problem has been determined to be |
| 153 | +a bug and cannot be quickly solved, you may be asked to file a bug in |
| 154 | +the tracker so the issue doesn't get lost. |
| 155 | + |
| 156 | +.. _git-trouble: |
| 157 | + |
| 158 | +Problems with recent git versions |
| 159 | +================================= |
| 160 | + |
| 161 | +First, make sure you have a clean build and install (see :ref:`clean-install`), |
| 162 | +get the latest git update, install it and run a simple test script in debug |
| 163 | +mode:: |
| 164 | + |
| 165 | + rm -rf /path/to/site-packages/matplotlib* |
| 166 | + git clean -xdf |
| 167 | + git pull |
| 168 | + python -m pip install -v . > build.out |
| 169 | + python -c "from pylab import *; set_loglevel('debug'); plot(); show()" > run.out |
| 170 | + |
| 171 | +and post :file:`build.out` and :file:`run.out` to the `matplotlib-devel |
| 172 | +<https://mail.python.org/mailman/listinfo/matplotlib-devel>`_ |
| 173 | +mailing list (please do not post git problems to the `users list |
| 174 | +<https://mail.python.org/mailman/listinfo/matplotlib-users>`_). |
| 175 | + |
| 176 | +Of course, you will want to clearly describe your problem, what you |
| 177 | +are expecting and what you are getting, but often a clean build and |
| 178 | +install will help. See also :ref:`reporting-problems`. |
| 179 | + |
0 commit comments