pyinstaller安裝出現'NoneType' object has no attribute 'rfind'問題解決
阿新 • • 發佈:2019-02-01
pyinstaller出現’NoneType’ object has no attribute ‘rfind’問題解決
用pyinstaller-2.0在linux上打包一個檔案,直接執行的原始碼pyinstaller.py進行安裝:
./pyinstaller-2.0/pyinstaller.py -F main.py
報下面的錯誤:
Traceback (most recent call last):
File "./pyinstaller-2.0/pyinstaller.py", line 91, in <module>
main()
File "./pyinstaller-2.0/pyinstaller.py" , line 86, in main
run_build(opts, spec_file)
File "./pyinstaller-2.0/pyinstaller.py", line 50, in run_build
PyInstaller.build.main(spec_file, **opts.__dict__)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/build.py", line 1625, in main
build(specfile, buildpath)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/build.py" , line 1582, in build
execfile(spec)
File "/home/ChargerPlanning/PlanTaskImpl.spec", line 5, in <module>
hookspath=None)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/build.py", line 389, in __init__
self.__postinit__()
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/build.py" , line 315, in __postinit__
self.assemble()
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/build.py", line 475, in assemble
importTracker.analyze_script(script)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/imptracker.py", line 205, in analyze_script
return self.analyze_r('__main__')
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/imptracker.py", line 98, in analyze_r
newnms = self.analyze_one(name, nm, imptyp, level)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/imptracker.py", line 159, in analyze_one
mod = self.doimport(nm, ctx, fqname)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/imptracker.py", line 231, in doimport
mod = parent.doimport(nm)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/modules.py", line 119, in doimport
mod = self.subimporter.getmod(nm)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/impdirector.py", line 145, in getmod
mod = owner.getmod(nm)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/owner.py", line 135, in getmod
mod = self._modclass()(nm, pth, co)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/modules.py", line 83, in __init__
self.scancode()
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/modules.py", line 86, in scancode
self.imports, self.warnings, self.binaries, allnms = scan_code(self.co)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/utils.py", line 199, in scan_code
_, _, _, all_nested = scan_code(c, m, w, b, 1)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/utils.py", line 191, in scan_code
ctypesb, ctypesw = scan_code_for_ctypes(co, instrs, i)
File "/home/ChargerPlanning/pyinstaller-2.0/PyInstaller/depend/utils.py", line 279, in scan_code_for_ctypes
if bin != os.path.basename(bin):
File "/usr/local/lib/python2.7/posixpath.py", line 114, in basename
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
在網上查了一下,有人提到可能是之前版本pyinstaller的bug,於是嘗試更新最新版本pyinstaller:
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
然後再執行pyinstaller,問題解決,完美打包。