Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend_example with PyInstaller #1067

Open
1am opened this issue Oct 21, 2022 · 3 comments
Open

frontend_example with PyInstaller #1067

1am opened this issue Oct 21, 2022 · 3 comments

Comments

@1am
Copy link

1am commented Oct 21, 2022

Hello.

I'm just asking since I'm curious about one aspect of the project. While trying to make a standalone binary from the frontend_example.py, it launches but I end up with a "500: Internal Server Error" message in the browser. This is it, no error in terminal. I assume that the binary isn't bundling the correct resources or that the path is different than when running from local script like in SO thread Bundling data files with PyInstaller (--onefile).

If the above assumption would be correct, most likely I'd have to figure out a way to swizzle the path to openhtf/openhtf/output/web_gui/dist/ folder so that the server serves these contents or something else would be necessary?

Best regards,

@1am
Copy link
Author

1am commented Nov 10, 2022

In the end it's actually quite easy, just add this to datas

('../.venv/src/openhtf/openhtf/output/web_gui','./openhtf/output/web_gui')

You obviously will need to adjust the "../.venv/src/openhtf/openhtf/output/web_gui" to appropriate path for your dev env setup.

@1am 1am closed this as completed Nov 10, 2022
@glados-verma
Copy link
Collaborator

Thanks for reporting and identifying the issue! I'm reopening so that we can make this example work out of the box.

@glados-verma glados-verma reopened this Nov 10, 2022
@kzhuo333
Copy link

Adding more detail for those who have trouble following the above discussion.
I found two ways to do this for my setup.
In my workfolder, I want to create an executable from a file called "main.py" and I have a ".venv" virtual environment folder containing the "web_gui" subfolder.

Method 1 using VSCode terminal:

pyinstaller --onefile --add-data .venv/Lib/site-packages/openhtf/output/web_gui;./openhtf/output/web_gui main.py

Method 2 in the form of a python script:

import PyInstaller.__main__

PyInstaller.__main__.run([
        'main.py',
        '--onefile',
        '--add-data',
        '.venv/Lib/site-packages/openhtf/output/web_gui;./openhtf/output/web_gui'
    ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants