无法打包使用 pyinstaller 导入的 matplotlib 的 python 脚本
Unable to package a python script which with matplotlib imported using pyinstaller
我正在尝试使用 pyinstaller 打包 python script。
- os:windows7 32
- python:2.7.9
- pyinstaller:2.0
我的代码包含以下导入:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Created Time: 2015/9/8 18:48:04
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import (
FigureCanvasQTAgg as FigureCanvas)
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
from matplotlib import rcParams
rcParams['font.sans-serif'] = ['SimHei']
rcParams['axes.unicode_minus'] = False
from PyQt4 import QtGui
from PyQt4 import QtCore
运行 CMD命令:
python pyinstaller.py matplot.py -D -w
输出:
Traceback (most recent call last):
File "pyinstaller.py", line 91, in <module>
main()
File "pyinstaller.py", line 86, in main
run_build(opts, spec_file)
File "pyinstaller.py", line 50, in run_build
PyInstaller.build.main(spec_file, **opts.__dict__)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 1625, in main
build(specfile, buildpath)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 1582, in build
execfile(spec)
File "F:\pyinstaller-2.0\matplot\matplot.spec", line 5, in <module>
hookspath=None)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 389, in __init__
self.__postinit__()
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 315, in __postinit__
self.assemble()
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 475, in assemble
importTracker.analyze_script(script)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 205, in analy
ze_script
return self.analyze_r('__main__')
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 98, in analyz
e_r
newnms = self.analyze_one(name, nm, imptyp, level)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 159, in analy
ze_one
mod = self.doimport(nm, ctx, fqname)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 256, in doimp
ort
hooks = __import__('PyInstaller.hooks', globals(), locals(), [hookmodnm])
TypeError: Item in ``from list'' not a string
感谢您的帮助!
它适用于 python3.4 pyqt5 pyinstaller-python3
谢谢!
我正在尝试使用 pyinstaller 打包 python script。
- os:windows7 32
- python:2.7.9
- pyinstaller:2.0
我的代码包含以下导入:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Created Time: 2015/9/8 18:48:04
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import (
FigureCanvasQTAgg as FigureCanvas)
from matplotlib.ticker import FuncFormatter
from matplotlib.ticker import MultipleLocator
from matplotlib import rcParams
rcParams['font.sans-serif'] = ['SimHei']
rcParams['axes.unicode_minus'] = False
from PyQt4 import QtGui
from PyQt4 import QtCore
运行 CMD命令:
python pyinstaller.py matplot.py -D -w
输出:
Traceback (most recent call last):
File "pyinstaller.py", line 91, in <module>
main()
File "pyinstaller.py", line 86, in main
run_build(opts, spec_file)
File "pyinstaller.py", line 50, in run_build
PyInstaller.build.main(spec_file, **opts.__dict__)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 1625, in main
build(specfile, buildpath)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 1582, in build
execfile(spec)
File "F:\pyinstaller-2.0\matplot\matplot.spec", line 5, in <module>
hookspath=None)
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 389, in __init__
self.__postinit__()
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 315, in __postinit__
self.assemble()
File "F:\pyinstaller-2.0\PyInstaller\build.py", line 475, in assemble
importTracker.analyze_script(script)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 205, in analy
ze_script
return self.analyze_r('__main__')
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 98, in analyz
e_r
newnms = self.analyze_one(name, nm, imptyp, level)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 159, in analy
ze_one
mod = self.doimport(nm, ctx, fqname)
File "F:\pyinstaller-2.0\PyInstaller\depend\imptracker.py", line 256, in doimp
ort
hooks = __import__('PyInstaller.hooks', globals(), locals(), [hookmodnm])
TypeError: Item in ``from list'' not a string
感谢您的帮助!
它适用于 python3.4 pyqt5 pyinstaller-python3 谢谢!