Search code examples
pythonlinuxpython-2.7pipwine

Pip returning syntax error when installing package in Python 2.7


I am trying to install a Python package in Wine, but it keeps giving me internal syntax errors. When I tried to install pyinstaller, it gave me this:

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

I have tried uninstalling and reinstalling using get-pip.py, and it's always the same error.

I am using Python 2.7.18 and Wine 4.0. Can anyone tell me how to fix this?


Solution

  • If Python 2.7 absolutely needs to be used, using the last supported version should still work. Please try

    pip install pyinstaller==3.6
    

    See also: How do you downgrade pyinstaller using pip?