Pas capable de tracer le graphique: matplotlib est nécessaire pour le traçage
Je suis en mesure de générer *.dat fichier:
vikas@server:~/memory_profiler-0.36$ ./mprof run --python test_sl.py
vikas@server:~/memory_profiler-0.36$ ls *.dat
mprofile_20151001035123.dat
Mais quand je suis en train de tracer le graphique, puis il dit "matplotlib est nécessaire pour tracer les"
vikas@server:~/memory_profiler-0.36$ ./mprof plot --output=plot.png
matplotlib is needed for plotting.
Ai-je raté quelque chose?
Fonction je suis de profilage est run() qui est à l'intérieur: file_to_be_profiled.py
#!/usr/bin/python
import time
import os, sys, commands
from memory_profiler import profile
from guppy import hpy
@profile
def run():
d = {}
l = []
hp = hpy()
before = hp.heap()
d["k1"] = 'val1'
d["k2"] = 10
count = 0
while (count < 9):
l.append(count)
print 'The count is:', count
count = count + 1
print "Good bye!"
after = hp.heap()
leftover = after - before
print leftover
if __name__ == '__main__':
sys.exit(run())
Et je suis en invoquant run() de mon script de test: test_sl.py:
#!/usr/bin/python
import commands
# for the time being I am running my test to profile method: run() inside file_to_be_profiled.py
run_cmd = './file_to_be_profiled.py
commands.getstatusoutput(run_cmd)
Je suis en cours d'exécution sur la machine ubuntu. Mais apt-get install n'a pas fonctionné pour moi. Puis j'ai fait l'installation à partir des sources. Mais ensuite, j'obtiens la même erreur.
apt-get a échoué:
vikas@server:~/memory_profiler-0.36$ sudo apt-get install -y python-matplotlib
[sudo] password for vikaskuk:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-matplotlib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-matplotlib' has no installation candidate
vikask@server:~/memory_profiler-0.36$ ./mprof plot --output=plot.png
matplotlib is needed for plotting.
Puis j'ai tenté pip install... qui n'a pas passer par:
vikas@server:~/memory_profiler-0.36$ pip install matplotlib
Downloading/unpacking matplotlib
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement matplotlib
Cleaning up...
No distributions at all found for matplotlib
Storing debug log for failure in /home/vikaskuk/.pip/pip.log
Enfin j'ai essayé d'installer à partir des sources qui semble être réussi:
vikas@server:~/memory_profiler-0.36$ cd ../matplotlib
vikas@server:~/matplotlib$ cd matplotlib-master/
(virtualenv)vikaskuk@beehive:~/matplotlib/matplotlib-master$ vi INSTALL
(virtualenv)vikaskuk@beehive:~/matplotlib/matplotlib-master$ python setup.py build
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.5.dev1]
python: yes [2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC
4.4.5]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [not found. pip may install it below.]
six: yes [using six version 1.5.2]
dateutil: yes [using dateutil version 2.1]
pytz: yes [pytz was not found. pip will attempt to install
it after matplotlib.]
tornado: yes [tornado was not found. It is required for the
WebAgg backend. pip/easy_install may attempt to
install it after matplotlib.]
pyparsing: yes [pyparsing was not found. It is required for
mathtext support. pip/easy_install may attempt to
install it after matplotlib.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' could not
be found.]
qhull: yes [pkg-config information for 'qhull' could not be
found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [using nose version 1.3.0 / using mock 1.0.1]
toolkits_tests: yes [using nose version 1.3.0 / using mock 1.0.1]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PyQt5 not found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: no [The C/C++ header for Tk (tk.h) could not be
found. You may need to install the development
package.]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: yes [version 8.71]
latex: yes [version 3.1415926]
pdftops: no
============================================================================
* The following required packages can not be built:
* freetype, png
(virtualenv)vikaskuk@beehive:~/matplotlib/matplotlib-master$ python setup.py install
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.5.dev1]
python: yes [2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC
4.4.5]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [not found. pip may install it below.]
six: yes [using six version 1.5.2]
dateutil: yes [using dateutil version 2.1]
pytz: yes [pytz was not found. pip will attempt to install
it after matplotlib.]
tornado: yes [tornado was not found. It is required for the
WebAgg backend. pip/easy_install may attempt to
install it after matplotlib.]
pyparsing: yes [pyparsing was not found. It is required for
mathtext support. pip/easy_install may attempt to
install it after matplotlib.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
freetype: no [The C/C++ header for freetype2 (ft2build.h)
could not be found. You may need to install the
development package.]
png: no [pkg-config information for 'libpng' could not
be found.]
qhull: yes [pkg-config information for 'qhull' could not be
found. Using local copy.]
OPTIONAL SUBPACKAGES
sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [using nose version 1.3.0 / using mock 1.0.1]
toolkits_tests: yes [using nose version 1.3.0 / using mock 1.0.1]
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PyQt5 not found]
qt4agg: no [PySide not found; PyQt4 not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: no [The C/C++ header for Tk (tk.h) could not be
found. You may need to install the development
package.]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: no [Microsoft Windows only]
OPTIONAL LATEX DEPENDENCIES
dvipng: no
ghostscript: yes [version 8.71]
latex: yes [version 3.1415926]
pdftops: no
============================================================================
* The following required packages can not be built:
* freetype, png
Mais quand j'essaie de tracer le graphique, j'ai frappé le problème d'origine:
vikas@server:~/matplotlib/matplotlib-master$ cd ../../memory_profiler-0.36
vikas@server:~/memory_profiler-0.36$ ./mprof plot --output=plot.png
matplotlib is needed for plotting.
J'ai pu réussir à faire apt-get update(il y avait des problème de firewall et puis j'ai réussi à faire: sudo apt-get install-y python-matplotlib.
Mais encore, je reçois un problème lors de l'exécution de mprof:
vikas@server:~/memory_profiler-0.36$ ./mprof plot --output=plot.png
Using last profile data.
Traceback (most recent call last):
File "./mprof", line 494, in <module>
actions[get_action()]()
File "./mprof", line 454, in plot_action
pl.figure(figsize=(14, 6), dpi=90)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Pourquoi ai-je besoin pour régler l'affichage? Je travaille sur ubuntu hébergé machine.
freetype
ou libpng
installé sur votre machine, de sorte que matplotlib ne peut pas construire. pip install
a couru dans un problème distinct (vous êtes derrière un pare-feu?), mais qui aurait frappé que des os peu de temps après. Je ne suis pas sûr de savoir pourquoi vous rencontrez des problèmes d'installation via le gestionnaire de paquets, mais apt-get install libfreetype6-dev
, libpng-dev
, et python-tk
et puis, vous devriez être en mesure de construire à partir de la source.
OriginalL'auteur vikas | 2015-10-01
Vous devez vous connecter pour publier un commentaire.
Vous devez installer
matplotlib
, en tant que chargé (cette erreur renvoyée parmprof
quand il ne peut pas trouvermatplotlib
).Vous pouvez le faire en utilisant pip
pip install matplotlib
(vous pourriez avoir besoin de faire précéder cette avecsudo
) ou votre gestionnaire de paquets:sudo apt-get install -y python-matplotlib
sur Debian, Ubuntu et dérivés.sudo yum install -y python-matplotlib
sur RHEL, CentOS et les produits dérivés.Assurez-vous d'expliquer pourquoi
apt-get install
ne fonctionne pas pour vous. Est-il un message d'erreur?Il peut y avoir une sorte de pare-feu dans mon organisation... c'est pourquoi apt-get aurait échoué. J'ai donc tenté d'installer depuis les sources qui ressemble a réussi. Mais aussi originale problème persiste. Veuillez voir ma question initiale.... j'ai édité maintenant, avec ce que tout ce que je fait.
Non, la source de l'échec de l'installation (voir à la fin de la sortie). Essayez d'exécuter
sudo apt-get update
avant d'exécuterapt-get install
. Vous allez avoir besoin de faire desapt-get
travail à un certain point, parce que vous êtes absent beaucoup de dépendances pourmatplotlib
etapt-get
est réellement la seule façon de les obtenir.post réussie apt-get update j'ai pu installer matplotlib... mais encore mprof se plaint à propos de l'affichage. Merci de vous référer à la question d'origine. J'ai cité avec le message d'erreur que j'obtiens.
OriginalL'auteur Thomas Orozco
Il semble matplotlib: 3.0.1 ne vont pas bien avec python 3.7 conda de l'environnement.
df.plot() commande n'a pas pu être exécutée correctement montrant "ImportError: matplotlib est nécessaire pour complot", mais en fait matplotlib est installé.
J'ai essayé de déclasser matplotlib pour 3.0.0 alors tout va bien.
conda installer -n [your_conda_envionment] matplotlib==3.0.0
OriginalL'auteur Shang Yang
J'ai eu le même problème. J'ai utilisé memory_profiler lib tapant cette commande
(
mprof run runner.py
etmprof plot
) et reçu un message "matplotlib est nécessaire pour tracer les"J'ai essayé de me débarrasser de ce problème en suivant les conseils que j'ai trouvé ici, mais dans le résultat, j'ai résolu ce problème de la réalisation de ces étapes simples:
supprimer les fichiers dans /usr/lib64/python2.7/site-packages/connecté avec matplotlib (ou vous pouvez désinstaller matplotlib à l'aide de la façon ordinaire)
utilisation
sudo yum-builddep python-matplotlib
pour installer connecté paquets (222 paquets ont été installés, si vous avez besoin d'apt-get, vous avez besoin de cette commande:sudo apt-get build-dep python-matplotlib
)installer matplotlib
sudo yum reinstall python-matplotlib
(ou utilisez la commande d'installation, avec apt-get:sudo apt-get install python-matplotlib
)Je crois que ça va aider.
OriginalL'auteur Vedanta6
J'ai eu le même problème sur freshely installé Ubuntu 16.04. Pour le résoudre, j'ai installé SciPy comme ceci:
sudo pip install scipy
Aussi, j'ai eu à installer
tkinter
lib comme ceci:sudo apt-get install python-tk
Je suppose que quelque part dans le passé, matplotlib avait
scipy
comme la dépendance, mais maintenant il n'a que numpy, tandis quemprof plot
nécessitescipy
.OriginalL'auteur Andrey Pokhilko