Matplotlib import probleme

Probleme bei der Installation?
Antworten
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Anfängerfrage: Ich habe mir das bundle pythonxy geladen. Bis auf matplotlib läuft alles tadellos. Beim Importiren von matplotlib bekomme ich die u.g. Fehlermedlung, kann aber nichts damit anfangen. Kann mir jemand weiter helfen ?

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\__init__.py", line 694, in <module>
rcParams = rc_params()
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\__init__.py", line 615, in rc_params
fname = matplotlib_fname()
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\__init__.py", line 565, in matplotlib_fname
fname = os.path.join(get_configdir(), 'matplotlibrc')
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\__init__.py", line 240, in wrapper
ret = func(*args, **kwargs)
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\__init__.py", line 439, in _get_configdir
raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
RuntimeError: Failed to create C:\/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data

MB
ms4py
User
Beiträge: 1178
Registriert: Montag 19. Januar 2009, 09:37

Google-Stichwort: Failed to create %s/.matplotlib
liefert genügend Ergebnisse. Kann sie nicht anschauen, da viele Seiten gesperrt sind, aber ich denke mal, dass die die Lösung dabei ist...
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Vielen Dank erst einmal. Für mich sieht es so aus, als ob auf ein Verzeichnis geschrieben werden soll, wo kein Zugriff für vorhanden ist. Die Fehlermeldung schlägt ja vor:
consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
Was ist damit gemeint ?
ms4py
User
Beiträge: 1178
Registriert: Montag 19. Januar 2009, 09:37

Hast du Schreibrechte auf C: ?
Versuch mal das in der Python-Konsole:

Code: Alles auswählen

>>> import os
>>> os.mkdir("C:\/.matplotlib")
Hier noch was:
http://matplotlib.sourceforge.net/faq/e ... lconfigdir
Setz die Variable einfach auf ein Verzeichnis, auf das du Zugriff hast.
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Super, Vielen Dank. Nach dem Erstellen von .matplotlib konnte ich es importieren. Dann bin ich aber auf das nächste Problem beim importieren von pylab gestossen mit der folgenden Fehlermeldung:
>>> from pylab import*

Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
from pylab import*
File "C:\Program Files\pythonxy\python\Lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\pylab.py", line 206, in <module>
from matplotlib import mpl # pulls in most modules
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
from matplotlib import artist
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
import matplotlib.cbook as cbook
AttributeError: 'module' object has no attribute 'cbook'[/quote
]

Wie kann ein einzelnes Modul fehlen ?
MB
ms4py
User
Beiträge: 1178
Registriert: Montag 19. Januar 2009, 09:37

Importiere halt mal gezielt die einzelnen Module und nicht mit "import *".
Bekommst du dann immer noch diesen Fehler?

Ansonsten, falls du nur matplotlib und nicht die anderen Packages von pythonxy benötigst, nimm mal eine Python-Standardinstallation und installier matplotlib und numpy manuell.

Installationsdateien für die 2 Packages für Python 2.6 findest du, wenn du hier im Forum nach meinen Beiträgen suchst.
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Ja, egal welches package ich importieren will, ich bekomme die Fehlermeldung, dass
File "C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\artist.py", line 4, in <module>
import matplotlib.cbook as cbook
AttributeError: 'module' object has no attribute 'cbook'
>>> from matplotlib import pylab
Aber trotzdem, Danke für die Mühe.
ms4py
User
Beiträge: 1178
Registriert: Montag 19. Januar 2009, 09:37

Existiert die Datei "cbook.py" in C:\Program Files\pythonxy\python\Lib\site-packages\matplotlib\ ?
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Ja, ist vorhanden, wie auch alle anderen.

Aber:!! es funktioniert. Super.

Vielen Dank; ice2k3
ms4py
User
Beiträge: 1178
Registriert: Montag 19. Januar 2009, 09:37

Und was ist deine Lösung bzw. war dein Fehler?
MB
User
Beiträge: 19
Registriert: Montag 5. Januar 2009, 15:07

Ich vermute zum Einen das Erstellen von .matplotlib
und dann bin ich noch mal raus aus python, und nach einem neuen Aufruf konnte ich die einzelnen Module aufrufen.
Auf jeden Fall hat es funktioniert; klingt das logisch?
Antworten