Quantcast
Viewing all articles
Browse latest Browse all 14069

How to un pyinstaller converted python app with Shiny for Python

I downloaded and installed Python 3.10.6 on windows 10 pro, installed Shiny for Python, created the sample app and run it. This worked fine.

I installed pyinstaller and converted the app to an exe. I tried to run the app it threw (please see below).

Does anyone know if this can work and if so how?

This is the file2.spec that worked:

# -*- mode: python ; coding: utf-8 -*-block_cipher = Noneimport os# /c/Users/raz/AppData/Local/Programs/Python/Python310/Lib/site-packages/shiny = os.path.abspath("../AppData/Local/Programs/Python/Python310/Lib/site-packages/shiny")a = Analysis(    ['file2.py'],    pathex=[],    binaries=[],    datas=[('app.py', '/'), (shiny,'/shiny')],    hiddenimports=[],    hookspath=[],    hooksconfig={},    runtime_hooks=[],    excludes=[],    win_no_prefer_redirects=False,    win_private_assemblies=False,    cipher=block_cipher,    noarchive=False,)pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)exe = EXE(    pyz,    a.scripts,    a.binaries,    a.zipfiles,    a.datas,    [],    name='file2',    debug=False,    bootloader_ignore_signals=False,    strip=False,    upx=True,    upx_exclude=[],    runtime_tmpdir=None,    console=True,    disable_windowed_traceback=False,    argv_emulation=False,    target_arch=None,    codesign_identity=None,    entitlements_file=None,)

This below did not work:

raz@rays8350 MINGW64 ~/shiny$ cat app.pyfrom shiny import App, render, uiapp_ui = ui.page_fluid(    ui.h2("Hello Shiny!"),    ui.input_slider("n", "N", 0, 100, 20),    ui.output_text_verbatim("txt"),)def server(input, output, session):    @output    @render.text    def txt():        return f"n*2 is {input.n() * 2}"app = App(app_ui, server)raz@rays8350 MINGW64 ~/shiny$raz@rays8350 MINGW64 ~/shiny$ ../AppData/Local/Programs/Python/Python310/Scripts/shiny.exe run --reload dist/app/app.exeINFO:     Will watch for changes in these directories: ['C:\\Users\\raz\\shiny\\dist\\app']INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)INFO:     Started reloader process [23368] using StatReloadProcess SpawnProcess-1:Traceback (most recent call last):  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 314, in _bootstrap    self.run()  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 108, in run    self._target(*self._args, **self._kwargs)  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\_subprocess.py", line 76, in subprocess_started    target(sockets=sockets)  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 60, in run    return asyncio.run(self.serve(sockets=sockets))  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run    return loop.run_until_complete(main)  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete    return future.result()  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 67, in serve    config.load()  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\config.py", line 479, in load    self.loaded_app = import_from_string(self.app)  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\importer.py", line 24, in import_from_string    raise exc from None  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string    module = importlib.import_module(module_str)  File "C:\Users\raz\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlockedModuleNotFoundError: No module named 'app'

Viewing all articles
Browse latest Browse all 14069

Trending Articles