我正在使用Python2.7。我无法使用Pyinstaller创建.exe文件,我想打包color.py文件。此文件已导入一个appJar。这是代码:
from appJar import gui
redWords = ("string", "integer", "boolean", "real")
greenWords = ("print", "input")
def highlightSyntax(param):
for w in redWords:
app.textAreaTagPattern("ta", "red", w)
for w in greenWords:
app.textAreaTagPattern("ta", "green", w)
with gui("Text Editor", "300x400") as app:
app.text("ta", focus=True, change=highlightSyntax)
app.textAreaCreateTag("ta", "red", background="yellow", foreground="black")
app.textAreaCreateTag("ta", "green", background="green", foreground="white")
然后我去了cmd并找到了路径,然后: C:\ Python27 \ demos> pyinstaller -F color.py
C:\Python27\demos>pyinstaller -F color.py
111 INFO: PyInstaller: 3.4
111 INFO: Python: 2.7.15
111 INFO: Platform: Windows-10-10.0.17134
116 INFO: wrote C:\Python27\demos\color.spec
124 INFO: UPX is not available.
128 INFO: Extending PYTHONPATH with paths
['C:\\Python27\\demos', 'C:\\Python27\\demos']
128 INFO: checking Analysis
128 INFO: Building Analysis because Analysis-00.toc is non existent
128 INFO: Initializing module dependency graph...
136 INFO: Initializing module graph hooks...
208 INFO: running Analysis Analysis-00.toc
216 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
required by c:\python27\python.exe
371 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest
371 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
376 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4137_none_f47d3254f657e518.manifest
376 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
380 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_f47b6862f65971de.manifest
523 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9415_none ...
527 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_508df7e2bcbccb90.manifest
531 INFO: Searching for file msvcr90.dll
531 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_508df7e2bcbccb90\msvcr90.dll
531 INFO: Searching for file msvcp90.dll
531 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_508df7e2bcbccb90\msvcp90.dll
535 INFO: Searching for file msvcm90.dll
535 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_508df7e2bcbccb90\msvcm90.dll
683 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_60a5df56e60dc5df.manifest
687 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest
687 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4137_none_f47d3254f657e518.manifest
690 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_f47e1bd6f6571810.manifest
690 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9415_none_f47b6862f65971de.manifest
690 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9415)
838 INFO: Caching module hooks...
855 INFO: Analyzing C:\Python27\demos\color.py
5850 INFO: Processing pre-safe import module hook _xmlplus
6110 INFO: Processing pre-find module path hook distutils
7623 INFO: Processing pre-safe import module hook six.moves
Traceback (most recent call last):
File "c:\python27\lib\site-packages\site.py", line 73, in <module>
__boot()
File "c:\python27\lib\site-packages\site.py", line 33, in __boot
imp.load_module('site',stream,path,descr)
File "c:\python27\lib\site.py", line 539, in <module>
main()
File "c:\python27\lib\site.py", line 528, in main
aliasmbcs()
File "c:\python27\lib\site.py", line 456, in aliasmbcs
import locale, codecs
File "c:\python27\lib\locale.py", line 17, in <module>
import functools
File "c:\python27\lib\site-packages\functools.py", line 72, in <module>
globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
AttributeError: 'module' object has no attribute 'compose'
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\python27\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python27\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 17, in <module>
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "c:\python27\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\python27\lib\site-packages\PyInstaller\building\build_main.py", line 443, in assemble
priority_scripts.append(self.graph.run_script(script))
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 201, in run_script
self._top_script_node = super(PyiModuleGraph, self).run_script(pathname)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1348, in run_script
self._scan_code(m, co, co_ast)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
self._process_imports(module)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1421, in import_hook
source_package, target_module_partname, level)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1573, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
m = self._load_package(fqname, pathname, packagepath)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
self._load_module(fqname, fp, buf, stuff)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
self._scan_code(m, co, co_ast)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
self._process_imports(module)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
self._scan_code(m, co, co_ast)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
self._process_imports(module)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1421, in import_hook
source_package, target_module_partname, level)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1590, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
m = self._load_package(fqname, pathname, packagepath)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
self._load_module(fqname, fp, buf, stuff)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
self._scan_code(m, co, co_ast)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
self._process_imports(module)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2417, in _safe_import_hook
edge_attr=edge_attr)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1438, in import_hook
target_module, target_attr_names):
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1726, in _import_importable_package_submodules
attr_name, submodule_name, package)
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
m = self._load_package(fqname, pathname, packagepath)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
self._load_module(fqname, fp, buf, stuff)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
self._scan_code(m, co, co_ast)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
self._process_imports(module)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "c:\python27\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "c:\python27\lib\site-packages\PyInstaller\depend\analysis.py", line 260, in _safe_import_module
hook_module.pre_safe_import_module(hook_api)
File "c:\python27\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-six.moves.py", line 69, in pre_safe_import_module
for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'
C:\Python27\demos>
所以有这个问题: 对于real_module_name,real_to_six_module_name.items()中的six_module_name: AttributeError:“ str”对象没有属性“ items”,
为解决此问题,我使用
像其他所有答案一样更新了setuptoolspip install --upgrade setuptools --ignore-installed
,但是又发生了。然后我更新了pyinstaller,它仍然无法正常工作。
我试图只用一行代码打包一个helloWorld.py文件
print 'HelloWorld'
这次成功了,所以我猜我的pyinstaller可以了。所以我猜我在导入appJar之后会出现AttributeError。
我也将appJar文件夹复制到了.py文件的同一文件夹下。没什么。
这个错误今天发生了,但是几个星期前,我已经将.exe文件与appJar和pyinstaller一起成功打包了。而且我并没有真正接触到我的环境。所以我不知道为什么这次失败了。
我该如何解决这个问题?