2016-04-01 6 views
1

Ich habe ein PyQt4-App-Projekt, das ich gerne in eine .exe unter Windows umwandeln würde. I cd zum Hauptskript und pyinstaller SPCanalyse.py ausführen. Wenn ich versuche, die EXE-Datei ausführen, erhalte ich:ImportError: Name kann nicht importiert werden NavigationToolbar2QTAgg

C:\Users\user\Documents\BMDanalyse\BMDanalyse\BMDanalyse>C:\Users\user\Documents 
\BMDanalyse\BMDanalyse\BMDanalyse\dist\SPCanalyse\SPCanalyse.exe 
Traceback (most recent call last): 
    File "<string>", line 12, in <module> 
ImportError: cannot import name NavigationToolbar2QTAgg 
SPCanalyse returned -1 

this Lesen habe ich versuche, von matplotlib.backends.backend_qt4agg import NavigationToolbar2QT an die Spitze der SPCanalyse.py aber ohne Erfolg hinzuzufügen. Obwohl ich überrascht bin, habe ich immer noch den Fehler, da es aussieht, als hätten sie es behoben.

Ich habe Matplotlib Version 1.5.1 und ich habe gefunden, dass NavigationToolbar2QTAgg was removed in dieser Version, die ich sicher habe, mit warum habe ich den Fehler bekommen. Also, wenn es entfernt wurde, warum versucht mein Code es zu importieren? Wie verhindere ich diesen versuchten Import?

Beachten Sie, dass ich keine Probleme habe, meine App auf Ubuntu zu starten.

Cmd ausgegeben, wenn pyinstaller ausgeführt wird:

D:\Home\Downloads\BMDanalyse\BMDanalyse>pyinstaller SPCanalyse.py 
49 INFO: PyInstaller: 3.1.1 
49 INFO: Python: 2.7.11 
49 INFO: Platform: Windows-7-6.1.7601-SP1 
49 INFO: wrote D:\Home\Downloads\BMDanalyse\BMDanalyse\SPCanalyse.spec 
49 INFO: UPX is not available. 
49 INFO: Extending PYTHONPATH with paths 
['D:\\Home\\Downloads\\BMDanalyse', 
'D:\\Home\\Downloads\\BMDanalyse\\BMDanalyse'] 
59 INFO: checking Analysis 
89 INFO: Building because c:\python27\lib\site-packages\numpy\linalg\__init__.py 
changed 
89 INFO: Initializing module dependency graph... 
99 INFO: Initializing module graph hooks... 
119 INFO: running Analysis out00-Analysis.toc 
129 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable 
    required by c:\python27\python.exe 
200 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 
200 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest 
200 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4926_none_f47c47b2f658b4a8.manifest 
200 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest 
269 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.307 
29.4940_none ... 
279 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8 
b3b9a1e18e3b_9.0.30729.4940_none_50916076bcb9a742.manifest 
279 INFO: Searching for file msvcr90.dll 
279 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9 
.0.30729.4940_none_50916076bcb9a742\msvcr90.dll 
279 INFO: Searching for file msvcp90.dll 
279 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9 
.0.30729.4940_none_50916076bcb9a742\msvcp90.dll 
279 INFO: Searching for file msvcm90.dll 
279 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9 
.0.30729.4940_none_50916076bcb9a742\msvcm90.dll 
349 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 
349 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest 
349 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4926_none_f47c47b2f658b4a8.manifest 
349 INFO: Found C:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1f 
c8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest 
349 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 
30729, 4940) 
389 INFO: Analyzing D:\Home\Downloads\BMDanalyse\BMDanalyse\SPCanalyse.py 
1101 INFO: Processing pre-find module path hook distutils 
2987 INFO: Processing pre-safe import module hook _xmlplus 
3118 INFO: Processing pre-find module path hook site 
3118 INFO: site: retargeting to fake-dir 'c:\\python27\\lib\\site-packages\\PyIn 
staller\\fake-modules' 
3138 INFO: Processing pre-safe import module hook win32com 
4625 INFO: Processing pre-safe import module hook six.moves 
7777 INFO: Processing pre-find module path hook PyQt4.uic.port_v3 
7787 INFO: Processing pre-find module path hook PyQt4.uic.port_v2 
8948 INFO: Looking for import hooks ... 
8958 INFO: Processing hook hook-PySide.QtGui.py 
9345 INFO: Processing hook hook-distutils.py 
9345 INFO: Processing hook hook-sysconfig.py 
9345 INFO: Processing hook hook-xml.py 
9345 INFO: Processing hook hook-PIL.py 
9355 INFO: Excluding import 'FixTk' 
9355 INFO: Excluding import 'Tkinter' 
9355 INFO: Excluding import 'PyQt5' 
9355 WARNING: From PIL.ImageQt removing import PyQt5.qRgba 
9355 WARNING: From PIL.ImageQt removing import PyQt5.QPixmap 
9355 WARNING: From PIL.ImageQt removing import PyQt5 
9355 WARNING: From PIL.ImageQt removing import PyQt5.QImage 
9355 INFO: Excluding import 'PySide' 
9365 WARNING: From PIL.ImageQt removing import PySide.QtGui 
9365 WARNING: From PIL.ImageQt removing import PySide.QtGui.QPixmap 
9365 WARNING: From PIL.ImageQt removing import PySide.QtCore 
9365 WARNING: From PIL.ImageQt removing import PySide.QtCore.QBuffer 
9365 WARNING: From PIL.ImageQt removing import PySide.QtGui.QImage 
9365 WARNING: From PIL.ImageQt removing import PySide.QtCore.QIODevice 
9365 WARNING: From PIL.ImageQt removing import PySide.QtGui.qRgba 
9365 INFO: Excluding import 'PyQt4' 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtGui.QImage 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtCore 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtGui.QPixmap 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtCore.QIODevice 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtCore.QBuffer 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtGui.qRgba 
9365 WARNING: From PIL.ImageQt removing import PyQt4.QtGui 
9365 INFO: Processing hook hook-httplib.py 
9365 INFO: Processing hook hook-pydoc.py 
9365 INFO: Excluding import 'Tkinter' 
9365 WARNING: From pydoc removing import Tkinter 
9375 INFO: Processing hook hook-PyQt4.QtTest.py 
9375 INFO: Processing hook hook-PyQt4.py 
9375 INFO: Processing hook hook-_tkinter.py 
9486 INFO: checking Tree 
9527 INFO: checking Tree 
9537 INFO: Processing hook hook-matplotlib.backends.py 
9978 INFO: Matplotlib backend "GTK": ignored 
    Gtk* backend requires pygtk to be installed. 
10319 INFO: Matplotlib backend "GTKAgg": ignored 
    Gtk* backend requires pygtk to be installed. 
10523 INFO: Matplotlib backend "GTKCairo": ignored 
    No module named gtk 
10843 INFO: Matplotlib backend "MacOSX": ignored 
    cannot import name _macosx 
11184 INFO: Matplotlib backend "Qt4Agg": added 
11527 INFO: Matplotlib backend "Qt5Agg": added 
11858 INFO: Matplotlib backend "TkAgg": added 
12187 INFO: Matplotlib backend "WX": ignored 
    Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12 
12497 INFO: Matplotlib backend "WXAgg": ignored 
    Matplotlib backend_wx and backend_wxagg require wxPython >=2.8.12 
12710 INFO: Matplotlib backend "GTK3Cairo": ignored 
    Gtk3 backend requires pygobject to be installed. 
13029 INFO: Matplotlib backend "GTK3Agg": ignored 
    Gtk3 backend requires pygobject to be installed. 
13615 INFO: Matplotlib backend "WebAgg": added 
13845 INFO: Matplotlib backend "nbAgg": ignored 
    No module named IPython.display 
14167 INFO: Matplotlib backend "agg": added 
14496 INFO: Matplotlib backend "cairo": added 
14707 INFO: Matplotlib backend "emf": ignored 
    No module named backend_emf 
14917 INFO: Matplotlib backend "gdk": ignored 
    No module named gobject 
15238 INFO: Matplotlib backend "pdf": added 
15621 INFO: Matplotlib backend "pgf": added 
15965 INFO: Matplotlib backend "ps": added 
16290 INFO: Matplotlib backend "svg": added 
16621 INFO: Matplotlib backend "template": added 
16744 INFO: Processing hook hook-PIL.Image.py 
16934 INFO: Processing hook hook-matplotlib.py 
17151 INFO: Processing hook hook-PyQt4.uic.py 
17161 INFO: Processing hook hook-xml.dom.domreg.py 
17161 INFO: Processing hook hook-PyQt4.QtGui.py 
17421 INFO: Processing hook hook-pkg_resources.py 
17572 INFO: Processing hook hook-PySide.QtCore.py 
17644 INFO: Processing hook hook-certifi.py 
17644 INFO: Processing hook hook-pytz.py 
17714 INFO: Processing hook hook-pywintypes.py 
17881 INFO: Processing hook hook-setuptools.py 
17881 INFO: Processing hook hook-PIL.SpiderImagePlugin.py 
17881 INFO: Excluding import 'FixTk' 
17881 INFO: Excluding import 'Tkinter' 
17881 INFO: Processing hook hook-encodings.py 
18141 INFO: Processing hook hook-PyQt4.QtSvg.py 
18141 INFO: Processing hook hook-xml.etree.cElementTree.py 
18141 INFO: Processing hook hook-PySide.py 
18141 INFO: Processing hook hook-PyQt4.QtCore.py 
18201 INFO: Processing hook hook-PyQt4.QtOpenGL.py 
18201 INFO: Processing hook hook-win32com.py 
18261 INFO: Processing hook hook-pythoncom.py 
18471 INFO: Looking for ctypes DLLs 
18491 INFO: Analyzing run-time hooks ... 
18501 INFO: Including run-time hook 'pyi_rth_pkgres.py' 
18501 INFO: Including run-time hook 'pyi_rth_qt4plugins.py' 
18511 INFO: Including run-time hook 'pyi_rth_qt4plugins.py' 
18511 INFO: Including run-time hook 'pyi_rth__tkinter.py' 
18511 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py' 
18511 INFO: Including run-time hook 'pyi_rth_mplconfig.py' 
18511 INFO: Including run-time hook 'pyi_rth_mpldata.py' 
18532 INFO: Looking for dynamic libraries 
18922 INFO: Searching for assembly x86_Microsoft.VC90.MFC_1fc8b3b9a1e18e3b_9.0.2 
1022.8_none ... 
18922 INFO: Found manifest c:\python27\lib\site-packages\Pythonwin\Microsoft.VC9 
0.MFC.manifest 
18922 INFO: Searching for file mfc90.dll 
18922 INFO: Found file c:\python27\lib\site-packages\Pythonwin\mfc90.dll 
18922 INFO: Searching for file mfc90u.dll 
18922 INFO: Found file c:\python27\lib\site-packages\Pythonwin\mfc90u.dll 
18922 INFO: Searching for file mfcm90.dll 
18922 INFO: Found file c:\python27\lib\site-packages\Pythonwin\mfcm90.dll 
18922 INFO: Searching for file mfcm90u.dll 
18922 INFO: Found file c:\python27\lib\site-packages\Pythonwin\mfcm90u.dll 
18993 INFO: Adding redirect Microsoft.VC90.MFC version (9, 0, 21022, 8) -> (9, 0 
, 21022, 8) 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PyQt4.QtCore 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PyQt4.QtTest 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PyQt4.QtGui 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PyQt4.QtOpenGL 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PyQt4.QtSvg 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtCore 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.shiboken 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtTest 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtOpenGL 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtSvg 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtNetwork 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PySide.QtGui 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PIL._webp 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PIL._imagingtk 
19713 WARNING: Attempted to add Python module twice with different upper/lowerca 
ses: PIL._imaging 
19713 INFO: Looking for eggs 
19713 INFO: Using Python library C:\Windows\system32\python27.dll 
19713 INFO: Found binding redirects: 
[BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVers 
ion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 4940), publicKeyToken=u'1fc8b3b9a 
1e18e3b'), BindingRedirect(name=u'Microsoft.VC90.MFC', language=None, arch=u'x86 
', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 21022, 8), publicKeyToken=u'1f 
c8b3b9a1e18e3b')] 
19733 INFO: Warnings written to D:\Home\Downloads\BMDanalyse\BMDanalyse\build\SP 
Canalyse\warnSPCanalyse.txt 
20092 INFO: checking PYZ 
20092 INFO: Building because toc changed 
20102 INFO: Building PYZ (ZlibArchive) D:\Home\Downloads\BMDanalyse\BMDanalyse\b 
uild\SPCanalyse\out00-PYZ.pyz 
21024 INFO: checking PKG 
21024 INFO: Building because toc changed 
21024 INFO: Building PKG (CArchive) out00-PKG.pkg 
21056 INFO: Bootloader c:\python27\lib\site-packages\PyInstaller\bootloader\Wind 
ows-32bit\run.exe 
21056 INFO: checking EXE 
21057 INFO: Building because out00-EXE.toc is bad 
21059 INFO: Building EXE from out00-EXE.toc 
21059 INFO: Appending archive to EXE D:\Home\Downloads\BMDanalyse\BMDanalyse\bui 
ld\SPCanalyse\SPCanalyse.exe 
21065 INFO: checking COLLECT 
WARNING: The output directory "D:\Home\Downloads\BMDanalyse\BMDanalyse\dist\SPCa 
nalyse" and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)y 
24730 INFO: Removing dir D:\Home\Downloads\BMDanalyse\BMDanalyse\dist\SPCanalyse 

25009 INFO: Building COLLECT out00-COLLECT.toc 
25029 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25159 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25159 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qtcore.pyd 
25159 INFO: Updating resource type 24 name 2 language 1033 
25180 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25180 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.shiboken.pyd 
25180 INFO: Updating resource type 24 name 2 language 1033 
25190 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25190 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qttest.pyd 
25200 INFO: Updating resource type 24 name 2 language 1033 
25210 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25210 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qtopengl.pyd 
25210 INFO: Updating resource type 24 name 2 language 1033 
25220 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25230 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qtsvg.pyd 
25230 INFO: Updating resource type 24 name 2 language 1033 
25240 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25240 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qtnetwork.pyd 
25240 INFO: Updating resource type 24 name 2 language 1033 
25580 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25580 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside.qtgui.pyd 
25580 INFO: Updating resource type 24 name 2 language 1033 
25661 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25661 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\_elementtree.pyd 
25661 INFO: Updating resource type 24 name 2 language 1033 
25740 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25740 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\pyside-python2.7.dll 
25740 INFO: Updating resource type 24 name 2 language 1033 
25750 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25750 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\shiboken-python2.7.dll 
25760 INFO: Updating resource type 24 name 2 language 1033 
25780 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30 
729, 4940) 
25780 INFO: Updating manifest in C:\Users\Cornelis\AppData\Roaming\pyinstaller\b 
incache00_py27_32bit\qtnetwork4.dll 
25780 INFO: Updating resource type 24 name 2 language 1033 

D:\Home\Downloads\BMDanalyse\BMDanalyse> 
+0

Ich habe den Namen des Skripts jetzt verloren, aber NavigationToolbar2QTAgg in NavigationToolbar2QT in einem der PYQTGraph Skripts geändert wurde das Problem gelöst. Daher vermute ich, dass pyqtgraph noch nicht aktualisiert wurde, um das Entfernen der API zu reflektieren. – Frikster

Antwort

3

So habe ich jetzt diese eine Million Mal getan. Wenn Sie dies sehen:

C:\Python27\python.exe C:/Users/user/PycharmProjects/BMDanalyse/BMDanalyse/SPCanalyse.py 
Traceback (most recent call last): 
    File "C:/Users/user/PycharmProjects/BMDanalyse/BMDanalyse/SPCanalyse.py", line 14, in <module> 
    from pyqtgraph.widgets.MatplotlibWidget import MatplotlibWidget 
    File "C:\Python27\lib\site-packages\pyqtgraph\widgets\MatplotlibWidget.py", line 8, in <module> 
    from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar 
ImportError: cannot import name NavigationToolbar2QTAgg 

Gehen Sie auf die Codezeile in MatplotlibWidget.py und

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar 

Um dies ändern:

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar 

Ja, du Ändern Sie Backend-Code permanent für dieses Update . Nach dieser Änderung hatte ich keine Probleme. NavigationToolbar2QTAgg wurde entfernt in matplotlib 1.5.0

+0

nein es wird in 1.5.1 nicht entfernt. Ich benutze es jetzt. den gleichen Fehler bekommen. –

+0

Die API Changes scheint es deutlich in 1.5.0 entfernt zu löschen: http://matplotlib.org/devdocs/api/api_changes.html?highlight=navigationtoolbar2qtagg#remove-navigationtoolbar2qtagg "Remove NavigationToolbar2QTAgg - Keine Funktionalität über die Basis NavigationToolbar2Qt "<- das ist von ihren aufgeführten Änderungen – Frikster