无法在 python2.7.18 上安装 pyinstaller

Can't install pyinstaller on python2.7.18

我用python2.7.18 wheel 更新了,pip 也更新了。但我仍然遇到同样的错误。在 linux python 相同版本但在 windows 上给出错误。我该如何解决这个错误?

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\vinchi\appdata\local\temp\tmpbzv06v'
       cwd: c:\users\vinchi\appdata\local\temp\pip-install-x1nttk\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\vinchi\appdata\local\temp\pip-build-env-avmgyd\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\vinchi\appdata\local\temp\pip-build-env-avmgyd\overlay\Lib\site-packages\setuptools\build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "c:\users\vinchi\appdata\local\temp\pip-build-env-avmgyd\overlay\Lib\site-packages\setuptools\build_meta.py", line 243, in run_setup
      self).run_setup(setup_script=setup_script)
    File "c:\users\vinchi\appdata\local\temp\pip-build-env-avmgyd\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\vinchi\appdata\local\temp\tmpbzv06v' Check the logs for full command output.

在 python3 中,有许多不同的更改可能会使 pyinstaller 上的较新版本无法在 python2 上运行。为了解决这个问题,您必须执行以下操作之一:

  • 安装Python3 或
  • 安装支持 python 2.7 的特定 pyinstaller 版本,最新版本为 3.6。
pip install pyinstaller==3.6

我也强烈建议不要使用 python 2,因为它已经到了使用寿命的尽头,大多数人都在使用 python 3。对于少数使用 python 2 的人来说,他们这样做是因为他们很好奇,想要 运行 一些旧代码,或者将旧程序移植到 python 3。 (如果你想为 python3 安装 pyinstaller 并且你安装了两个 python 版本)

pip3 install pyinstaller

这将告诉程序您使用的是 python 3 的点而不是 python 2 的点。希望对您有所帮助!