2017-01-10 60 views
5

我写了一个小小的Python程序,大部分将要运行它的人都是Windows用户。我试图在两个不同的设备上使用pyinstaller和py2exe,一个使用Windows,另一个使用arch-linux。PyInstaller和Python3.6 - Tuple Index

我重新安装了一次以上,使用PIP 3安装pyinstaller --no缓存

我总是得到同样的错误:

sudo pyinstaller --windowed --onefile test.py 
49 INFO: PyInstaller: 3.2 
49 INFO: Python: 3.6.0 
50 INFO: Platform: Linux-4.8.13-1-ARCH-x86_64-with-arch 
51 INFO: wrote /home/XXXXX/test.spec 
52 INFO: UPX is not available. 
53 INFO: Extending PYTHONPATH with paths 
['/home/XXXXX', '/home/XXXXX'] 
54 INFO: checking Analysis 
54 INFO: Building Analysis because out00-Analysis.toc is non existent 
54 INFO: Initializing module dependency graph... 
57 INFO: Initializing module graph hooks... 
58 INFO: Analyzing base_library.zip ... 
Traceback (most recent call last): 
    File "/usr/bin/pyinstaller", line 11, in <module> 
    load_entry_point('PyInstaller==3.2', 'console_scripts', 'pyinstaller')() 
    File "/usr/lib/python3.6/site-packages/PyInstaller/__main__.py", line 90, in run 
    run_build(pyi_config, spec_file, **vars(args)) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build 
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 788, in main 
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 734, in build 
    exec(text, spec_namespace) 
    File "<string>", line 16, in <module> 
    File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 212, in __init__ 
    self.__postinit__() 
    File "/usr/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 178, in __postinit__ 
    self.assemble() 
    File "/usr/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 317, in assemble 
    excludes=self.excludes, user_hook_dirs=self.hookspath) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/depend/analysis.py", line 560, in initialize_modgraph 
    graph.import_hook(m) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 906, in import_hook 
    q, tail = self._find_head_package(parent, name, level) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 990, in _find_head_package 
    q = self._safe_import_module(head, qname, parent) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/depend/analysis.py", line 209, in _safe_import_module 
    module_basename, module_name, parent_package) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1211, in _safe_import_module 
    module_name, file_handle, pathname, metadata) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1295, in _load_module 
    self._scan_code(m, co, co_ast) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1460, in _scan_code 
    self._scan_bytecode_stores(co, m) 
    File "/usr/lib/python3.6/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 1505, in _scan_bytecode_stores 
    name = co.co_names[oparg] 
IndexError: tuple index out of range 

所以,在这种情况下,我只是用一个testscript包含:

#!/usr/bin/env python3.6 
print("hello world") 

确保导入没有问题等等。

+1

看起来像“Python 3.6尚未支持”。 https://github.com/pyinstaller/pyinstaller/issues/2286 – davedwards

+0

恩,感谢您的快速回答。可悲的是,在我的Windows机器上,当我输入pyinstaller.exe到cmd时,它无法创建一个进程。我会尝试修复这个问题,这里似乎有一个解决方案:https://stackoverflow.com/questions/31808180/installing-pyinstaller-via-pip-leads-to-failed-to-create-process – Simulacrum

回答

2

我遇到了python 3.6和pyinstaller的相同问题,并且第一次使用了cx_Freeze。它像一个魅力一样工作!

Setup.py内容:

import cx_Freeze 
exe = [cx_Freeze.Executable("downloads_folder.py")] 
cx_Freeze.setup(name = "downloads", 
       version = "1.0", 
       options = {"build_exe": {"packages": ["errno", "os", "re", "stat", "subprocess","collections","pprint","shutil", "humanize","pycallgraph"], "include_files": []}}, 
       executables = exe) 

setup.py是目录启动cmd,然后运行以下命令:蟒蛇的setup.py建立

可执行程序将在由cx_Freeze运行创建的构建目录中找到。

0

同样在这里,我也是新的,并得到了与你一样的问题。我被困约6个小时,并尝试了一切。最后我还安装了cx_freeze并且它工作了

pip install cx_freeze

3

Pyinstaller不支持Python 3,6呢。 你可以恢复到Python 3.5,或尝试提到的cx_Freeze解决方案...不知道它做了什么,但我认为它取代了它。