简体   繁体   English

无法在python2.7.18上安装pyinstaller

[英]Can't install pyinstaller on python2.7.18

I use python2.7.18 wheel updated, pip too.我也使用更新的 python2.7.18 wheel,pip。 But I still get the same error.但我仍然遇到同样的错误。 On linux python of the same version but on windows gives an error.同版本的linux python 但是windows 报错。 How can I fix this error?我该如何解决这个错误?

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.

In python3, there are a lot of different changes which could make newer versions on pyinstaller not work on python2.在 python3 中,有许多不同的更改可能会使 pyinstaller 上的较新版本无法在 python2 上运行。 In order to fix this you would have to either do one of the following:为了解决这个问题,您必须执行以下操作之一:

  • Install Python3 or安装 Python3 或
  • install a specific pyinstaller version that supports python 2.7, which the most updated one would be 3.6.安装支持 python 2.7 的特定 pyinstaller 版本,最新版本为 3.6。
pip install pyinstaller==3.6

I would also heavily advise against using python 2 because it has reached its end of life and most people use python 3. For the few people that use python 2, they do so because they are curious, want to run some old code, or to port over old programs into python 3. (In case you want to insall pyinstaller for python3 and you have both python versions installed)我也强烈建议不要使用 python 2,因为它已经到了生命的尽头,大多数人使用 python 3。对于少数使用 python 2 的人,他们这样做是因为他们很好奇,想运行一些旧代码,或者将旧程序移植到 python 3.(如果你想为 python3 安装 pyinstaller 并且你安装了两个 python 版本)

pip3 install pyinstaller

This will tell the program that you are using python 3's pip not python 2's.这将告诉程序您正在使用 python 3 的 pip 而不是 python 2 的。 I hope this helped!我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM