Python 2.7 到 EXE - 无法安装 pyinstaller

Python 2.7 to EXE - can't install pyinstaller

我正在使用 Win10 并且有一些代码是用 Python 2.7 编写的(必须是,它不是我的),我想创建一个 EXE 文件。 我想安装 pyinstaller 但无法安装。 我已经尝试更新 pip 版本,即 suteuptools,以安装“ez_setup”以从 pyinstaller 网站下载文件,但它没有帮助。

这些是我尝试下载它的方式:

pip install pyinstaller
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz
easy_install pyinstaller

这些是我收到的错误:

    C:\Users\roy.a\Desktop\work\EMV IL - cryptera\cryptera 
    Python\scripts\Activation python>easy_install pyinstaller
    WARNING: The easy_install command is deprecated and will be removed 
    in a future version.
    Searching for pyinstaller 
    Reading https://pypi.org/simple/pyinstaller/
    Downloading https://files.pythonhosted.org/packages/b6/27/a006fcadba0db30819c968eb8de 
   cb4937cda398ca7a44d8874172cdc228a/pyinstaller-4.3.tar.gz#sha256=5ecf8bbc230d7298a796e52bb745b95eee12878d141f1645612c99246ecd23f2
Best match: pyinstaller 4.3
Processing pyinstaller-4.3.tar.gz
Writing c:\users\roy.a\appdata\local\temp\easy_install-b2hzrm\pyinstaller-4.3\setup.cfg
Running pyinstaller-4.3\setup.py -q bdist_egg --dist-dir c:\users\roy.a\appdata\local\temp\easy_install-b2hzrm\pyinstaller-4.3\egg-dist-tmp-hmqf0j
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\easy_install.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 2321, in main
    **kw
  File "c:\python27\lib\site-packages\setuptools\__init__.py", line 162, in setup
    return distutils.core.setup(**attrs)
  File "c:\python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "c:\python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "c:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 424, in run
    self.easy_install(spec, not self.no_deps)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 685, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 711, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 896, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1164, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", line 1150, in run_setup
    run_setup(setup_script, args)
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
    raise
  File "c:\python27\lib\contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "c:\python27\lib\contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
    saved_exc.resume()
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 141, in resume
    six.reraise(type, exc, self._tb)
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
    yield saved
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
      File "c:\python27\lib\site-packages\setuptools\sandbox.py", line 44, 
    in _execfile
        code = compile(script, filename, 'exec')
      File "c:\users\roy.a\appdata\local\temp\easy_install- 
    b2hzrm\pyinstaller-4.3\setup.py", line 63
        file=sys.stderr)
        ^
    SyntaxError: invalid syntax

还有这个:

  C:\Users\roy.a\Desktop\work\EMV IL - cryptera\cryptera Python\scripts\Activation python>pip install pyinstaller
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pyinstaller
  Using cached pyinstaller-4.1.tar.gz (3.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'c:\users\roy.a\appdata\local\temp\tmpqtblxb'
       cwd: c:\users\roy.a\appdata\local\temp\pip-install-wcrcpk\pyinstaller
  Complete output (19 lines):
  Traceback (most recent call last):
    File "c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
      main()
    File "c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "c:\users\roy.a\appdata\local\temp\pip-build-env-blngut\overlay\Lib\site-packages\setuptools\build_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "c:\users\roy.a\appdata\local\temp\pip-build-env-blngut\overlay\Lib\site-packages\setuptools\build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "c:\users\roy.a\appdata\local\temp\pip-build-env-blngut\overlay\Lib\site-packages\setuptools\build_meta.py", line 243, in run_setup
      self).run_setup(setup_script=setup_script)
    File "c:\users\roy.a\appdata\local\temp\pip-build-env-blngut\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 63
      file=sys.stderr)
          ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python27\python.exe' 'c:\python27\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'c:\users\roy.a\appdata\local\temp\tmpqtblxb' Check the logs for full command output.

任何帮助将不胜感激 谢谢

changelog for PyInstaller 文档表明 Python 2.7 已被删除,因此您必须安装与 2.7 兼容的旧版本。

尝试使用 pip install pyinstaller==3.6 安装旧版本。

对于您需要的其他第三方模块,您可能必须执行类似的操作。