Python 2.7 to EXE – can't install pyinstaller

Question:

I’m using Win10 and have some code written in Python 2.7 (have to be, it’s not mine) and I want to create an EXE file.
I want to install pyinstaller but can’t do it.
I’ve already tried to update the pip version, the suteuptools, to install "ez_setup" to download the file from the pyinstaller website but it doesn’t help.

These are the ways I tried to download it:

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

And these are the errors I received:

    C:Usersroy.aDesktopworkEMV IL - crypteracryptera 
    PythonscriptsActivation 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:usersroy.aappdatalocaltempeasy_install-b2hzrmpyinstaller-4.3setup.cfg
Running pyinstaller-4.3setup.py -q bdist_egg --dist-dir c:usersroy.aappdatalocaltempeasy_install-b2hzrmpyinstaller-4.3egg-dist-tmp-hmqf0j
Traceback (most recent call last):
  File "c:python27librunpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:python27librunpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:Python27Scriptseasy_install.exe__main__.py", line 9, in <module>
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 2321, in main
    **kw
  File "c:python27libsite-packagessetuptools__init__.py", line 162, in setup
    return distutils.core.setup(**attrs)
  File "c:python27libdistutilscore.py", line 151, in setup
    dist.run_commands()
  File "c:python27libdistutilsdist.py", line 953, in run_commands
    self.run_command(cmd)
  File "c:python27libdistutilsdist.py", line 972, in run_command
    cmd_obj.run()
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 424, in run
    self.easy_install(spec, not self.no_deps)
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 685, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 711, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 896, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 1164, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "c:python27libsite-packagessetuptoolscommandeasy_install.py", line 1150, in run_setup
    run_setup(setup_script, args)
  File "c:python27libsite-packagessetuptoolssandbox.py", line 253, in run_setup
    raise
  File "c:python27libcontextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:python27libsite-packagessetuptoolssandbox.py", line 195, in setup_context
    yield
  File "c:python27libcontextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:python27libsite-packagessetuptoolssandbox.py", line 166, in save_modules
    saved_exc.resume()
  File "c:python27libsite-packagessetuptoolssandbox.py", line 141, in resume
    six.reraise(type, exc, self._tb)
  File "c:python27libsite-packagessetuptoolssandbox.py", line 154, in save_modules
    yield saved
  File "c:python27libsite-packagessetuptoolssandbox.py", line 195, in setup_context
    yield
  File "c:python27libsite-packagessetuptoolssandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
      File "c:python27libsite-packagessetuptoolssandbox.py", line 44, 
    in _execfile
        code = compile(script, filename, 'exec')
      File "c:usersroy.aappdatalocaltempeasy_install- 
    b2hzrmpyinstaller-4.3setup.py", line 63
        file=sys.stderr)
        ^
    SyntaxError: invalid syntax

And this:

  C:Usersroy.aDesktopworkEMV IL - crypteracryptera PythonscriptsActivation 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:python27python.exe' 'c:python27libsite-packagespip_vendorpep517_in_process.py' get_requires_for_build_wheel 'c:usersroy.aappdatalocaltemptmpqtblxb'
       cwd: c:usersroy.aappdatalocaltemppip-install-wcrcpkpyinstaller
  Complete output (19 lines):
  Traceback (most recent call last):
    File "c:python27libsite-packagespip_vendorpep517_in_process.py", line 280, in <module>
      main()
    File "c:python27libsite-packagespip_vendorpep517_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:python27libsite-packagespip_vendorpep517_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "c:usersroy.aappdatalocaltemppip-build-env-blngutoverlayLibsite-packagessetuptoolsbuild_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "c:usersroy.aappdatalocaltemppip-build-env-blngutoverlayLibsite-packagessetuptoolsbuild_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "c:usersroy.aappdatalocaltemppip-build-env-blngutoverlayLibsite-packagessetuptoolsbuild_meta.py", line 243, in run_setup
      self).run_setup(setup_script=setup_script)
    File "c:usersroy.aappdatalocaltemppip-build-env-blngutoverlayLibsite-packagessetuptoolsbuild_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:python27python.exe' 'c:python27libsite-packagespip_vendorpep517_in_process.py' get_requires_for_build_wheel 'c:usersroy.aappdatalocaltemptmpqtblxb' Check the logs for full command output.

Any help will be appreciated
Thanks

Asked By: Roy Ancri

||

Answers:

The changelog for PyInstaller documents that Python 2.7 has been dropped so you will have to install an older version that has compatibility with 2.7.

Try to install an older version using pip install pyinstaller==3.6.

You will likely have to do similar for other third-party modules that you require.

Answered By: AdamMcKay
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.