Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 6

Build Python app with PyInstaller in Github Actions

Solved! Go to Solution.

Hi there,

Is it possible to run PyInstaller and push the created .exe File into my Repository?

I tried to implement a Github workflow, which runs PyInstaller on a .py File. 

When I ran this script within my Github workflow I got the following error on the "build with pyinstaller" job :

Thanks in advance for your help :D


name: PyInstaller

on: [push]


    runs-on: windows-latest

    - uses: actions/checkout@v1
    - name: Set up Python 3.8
      uses: actions/setup-python@v1
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install pyinstaller
    - name: build with pyinstaller
      run: |




    exec(code, run_globals)
  File "C:\hostedtoolcache\windows\Python\3.8.0\x64\Scripts\pyinstaller.exe\", line 7, in <module>
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 791, in build
    exec(code, spec_namespace)
  File "D:\a\Test\Test\arbeitszeit.spec", line 18, in <module>
    pyz = PYZ(a.pure, a.zipped_data,
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 98, in __init__
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 158, in __postinit__
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 128, in assemble
    self.code_dict = {
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 652, in strip_paths_in_code
    consts = tuple(
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 653, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "c:\hostedtoolcache\windows\python\3.8.0\x64\lib\site-packages\PyInstaller\building\", line 660, in strip_paths_in_code
    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
##[error]Process completed with exit code 1.



5 Replies
Copilot Lvl 3
Message 2 of 6

Re: Build Python app with PyInstaller in Github Actions

Seems like my issue was caused by

Using Python 3.7 instead of 3.8 fixed the problem for me

Copilot Lvl 2
Message 3 of 6

Re: Build Python app with PyInstaller in Github Actions


Thank you for posting the solution.  I am a relative newbie to programming in general.  I have been writing short programs in Python for last 6 months and genuinely enoying it.  Also I updated my Python version just last week from 3.7.3 to 3.8.0.  However, while trying to create my very first ever .exe file(s) from a .py/.pyw file(s) (across any version in any programming language), I ran into the issue of TypeError (integer required but got bytes).  I researched and quickly stumbled across your recommended solution.  However, would you PLEASE PLEASE PLEASE take the time to explain what to do after installing a separate copy of Python 3.7.5 (the one I just installed).  I don't want to uninstall the 3.8.0 just yet.  What are the exact steps?  When I launch PowerShell (or Command Prompt) as Admin to create .exe, the 3.8 still shows up as my Python version.  Is there a command to manually switch to 3.7x when in PowerShell?  The 3.7.5 is working just fine if I use the Python IDLE / interpreter / iPython console in Spyder or PowerShell as a normal user.  Please explain the solution in simple English to a newbie.  Thank you much in advance!  Cheers

Copilot Lvl 2
Message 4 of 6

Re: Build Python app with PyInstaller in Github Actions


I figured out how to set up 3.7x as the default system environment variable.  Thanks again for posting the solutiuon,

Copilot Lvl 3
Message 5 of 6

Re: Build Python app with PyInstaller in Github Actions

Hey @al-ra1 ,


I think what you are looking for is some sort of virtual environment for your projects, like venv, pipenv or conda.

It is considered best practice to use a new virtual env for each of your projects. During creation of your venv you can define which Python version you want to use. Let's say you have Python 3.8 installed on your system, you can define any of 3.x versions for your virtual env. Additionally each project gets its own environment with all the third party libraries you want to install in it.

Consider reading through the following article:


Copilot Lvl 2
Message 6 of 6

Re: Build Python app with PyInstaller in Github Actions

Hi @lrwagner,

Thank you for taking the time to answer my prior question (and sorry for this delayed response).  I mentioned shortly after sending my initial request, I was able to solve my issue by directly changing the environment variable itself.  I also considered creating a virtual environment at the time, but couldn't decide if it was necessary.  I think next time on I'll consider switching between the two environments right from the Command Prompt/PowerShell interpreter window.  Also thank you for attaching the link to Python documentation in your response.