gpt4 book ai didi

python - 无法让 Pyinstaller 执行 python 文件

转载 作者:太空宇宙 更新时间:2023-11-03 15:12:10 24 4
gpt4 key购买 nike

我用Python 3.6编写了一个程序,我尝试使用Pyinstaller来执行它,但后来我发现Pyinstaller只能工作到Python 3.5,所以我下载了它并尝试执行该文件,但它仍然无法工作!我与它不同的错误找不到文件:

100 INFO: PyInstaller: 3.2.1
100 INFO: Python: 3.6.0
100 INFO: Platform: Windows-10-10.0.14393-SP0
100 INFO: wrote C:\Python\pyi-env-name\Scripts\ATM.spec
100 INFO: UPX is not available.
100 INFO: Extending PYTHONPATH with paths
['F:\\', 'C:\\Python\\pyi-env-name\\Scripts']
100 INFO: checking Analysis
100 INFO: Building Analysis because out00-Analysis.toc is non existent
100 INFO: Initializing module dependency graph...
100 INFO: Initializing module graph hooks...
100 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
File "c:\users\kirsty douglas\appdata\local\programs\python\python36\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\kirsty douglas\appdata\local\programs\python\python36\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python\pyi-env-name\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
self.__postinit__()
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
self.assemble()
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble
excludes=self.excludes, user_hook_dirs=self.hookspath)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
graph.import_hook(m)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
source_package, target_module_partname, level)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module
self._scan_code(m, co, co_ast)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
module, module_code_object, is_scanning_imports=False)
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode
global_attr_name = get_operation_arg_name()
File "c:\python\pyi-env-name\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operation_arg_name
return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range

我真的不知道还能尝试什么,我已经尝试了我能找到的所有教程,甚至我的老师也不知道发生了什么!

编辑::我刚刚意识到第二行写着

100 INFO: Python: 3.6.0

那么我怎样才能让它使用Python 3.5

最佳答案

(这可能应该是一条评论,但是......代表问题)

您发布的打印输出提到您将其作为 Python 3.6 运行。为了避免这种情况,您可能需要确保您的 PATH 变量仅包含您需要的安装; 3.5.

这至少应该修复您将其作为错误版本的 python 运行的问题。它可能无法解决其他问题。

编辑:Windows 中的环境变量:

  • 打开文件资源管理器,然后右键单击左侧 Pane 中的“此电脑”。
  • 在打开的上下文菜单中单击“属性”。
  • 在左侧 Pane 中,点击“高级系统设置”。
  • 在底部的“高级”选项卡下,点击“环境变量”。
  • 在顶部 Pane 中选择“路径”,然后点击“编辑”。
  • 将 python 路径更改为您需要的版本的位置。

关于python - 无法让 Pyinstaller 执行 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44137006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com