zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
10.1k stars 605 forks source link

Problem running a packaged app on Windows 7 #2172

Closed mrhanCH closed 10 months ago

mrhanCH commented 11 months ago

Description

I packaged a simple test code using pyinstaller, but after successful packaging, it cannot be opened on a Windows 7 system, prompting the following message. It seems that because the "shcore. DLL" dynamic library requires a minimum of Windows 8 system, has anyone successfully packaged and run the program on Windows 7 system?

NiceGUI ready to go on http://localhost:8000

未经处理的异常:  Python.Runtime.PythonException: Could not find module 'shcore' (or one of its dependencies). Try using the full path with constructor syntax.
   在 Python.Runtime.PythonException.ThrowLastAsClrException()
   在 Python.Runtime.Dispatcher.TrueDispatch(Object[] args)
   在 Python.Runtime.Dispatcher.Dispatch(Object[] args)
   在 __System_Threading_ThreadStartDispatcher.Invoke()
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Threading.ThreadHelper.ThreadStart()
rodja commented 11 months ago

Can you share your simple test program? Is it using native mode?

frankhuurman commented 11 months ago

@mrhanCH does the app run well without using pyinstaller?

Might have something to do with how pyinstaller packages the dependencies or if it knows what dependencies to use for NiceGUI's native mode.

If you've got a code example I could try to package and run it in a Win 7 VM.

Also I'm sure you know already but Windows 7 has been End of Life for almost 4 years and most Python versions that ran on Windows 7 are End of Life as well(I believe 3.8 is the last Python for Windows 7 and it's in legacy/security fixes only mode). Not saying that the app shouldn't be able to run but maybe pyinstaller uses a newer version of the shcore.dll library during packaging so it might be worth upgrading to a newer Windows to get it working.

mrhanCH commented 11 months ago

@mrhanCH does the app run well without using pyinstaller?

Might have something to do with how pyinstaller packages the dependencies or if it knows what dependencies to use for NiceGUI's native mode.

If you've got a code example I could try to package and run it in a Win 7 VM.

Also I'm sure you know already but Windows 7 has been End of Life for almost 4 years and most Python versions that ran on Windows 7 are End of Life as well(I believe 3.8 is the last Python for Windows 7 and it's in legacy/security fixes only mode). Not saying that the app shouldn't be able to run but maybe pyinstaller uses a newer version of the shcore.dll library during packaging so it might be worth upgrading to a newer Windows to get it working.

Yes, that's right. The maintenance of the Windows 7 system has ended, but some industrial computers or computers used by the elderly may still be using the Windows 7 system.

The application runs normally without using Pyinstaller. The code I am using is the simplest official example code.

Just because, my other projects were packaged using Pyinstaller and worked properly on the Windows 7 system, I am not sure which item in the NiceGui dependency package restricted Windows 7. It only mentioned the issue with the Shcore.dll library.

By the way, the error messages in the running results of the program packaged with Nuitka and Pyinstaller are exactly the same, which makes me suspect that it is a problem with my computer?

This is my packaging command and packaging log: And,This is the packaged program:https://drive.google.com/file/d/1rIa9XDH04RMs7tX0uhBlPkDpNpoQJuJA/view?usp=sharing

(venv) G:\HRB\AiLlive>pyinstaller -n Test --distpath v3out --hidden-import nicegui -D test.py 500 INFO: PyInstaller: 6.3.0 500 INFO: Python: 3.8.6 501 INFO: Platform: Windows-7-6.1.7601-SP1 502 INFO: wrote G:\HRB\AiLlive\Test.spec 508 INFO: Extending PYTHONPATH with paths ['G:\HRB\AiLlive'] pygame 2.5.0 (SDL 2.28.0, Python 3.8.6) Hello from the pygame community. https://www.pygame.org/contribute.html 1175 INFO: checking Analysis 1403 INFO: checking PYZ 1693 INFO: checking PKG 1732 INFO: Bootloader G:\HRB\AiLlive\venv\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe 1732 INFO: checking EXE 1806 INFO: Building because console changed 1806 INFO: Building EXE from EXE-00.toc 1808 INFO: Copying bootloader EXE to G:\HRB\AiLlive\build\Test\Test.exe 1834 INFO: Copying icon to EXE 1877 INFO: Copying 0 resources to EXE 1877 INFO: Embedding manifest in EXE 1886 INFO: Appending PKG archive to EXE 1895 INFO: Fixing EXE headers 2038 INFO: Building EXE from EXE-00.toc completed successfully. 2044 INFO: checking COLLECT 2096 INFO: Building COLLECT COLLECT-00.toc 3449 INFO: Building COLLECT COLLECT-00.toc completed successfully.

mrhanCH commented 11 months ago

Can you share your simple test program? Is it using native mode?

Please review .reply Yes, using native mode

mrhanCH commented 11 months ago

@falkoschindler @rodja I have tested on the WIN10 system and found that both Pyinstaller and Nuitka packaged programs run perfectly, but not on WIN7. My code:

from nicegui import native, ui

ui.label('Hello NiceGUI!')

ui.run(reload=False, port=native.find_open_port(), native=True)

1

mrhanCH commented 11 months ago

@rodja @falkoschindler Oh, if you use build.py to package directly, there will be different error messages when running the program: image image

falkoschindler commented 11 months ago

@mrhanCH Looks like you're missing the typing_extensions package. Have you tried installing it?

mrhanCH commented 10 months ago

After multiple system switching and packaging tests, it has been confirmed that the Windows 7 system is not supported. However, it is currently unclear which module does not support Windows 7 after packaging.

mrhanCH commented 10 months ago

@falkoschindler Hello, I think I have found the answer to this question.

The Pywebview package has never supported Windows 7 systems, and the author has provided a response to this.

Please refer to: pywebview#891 .

happylittle2010 commented 4 days ago

When packaging NiceGUI using the native mode, it utilizes pywebview, which is no longer officially supported on Windows 7.

Solution: Install the .NET 4.7.2 runtime and the Edge WebView2 Runtime 109 (109 is the last version that supports Windows 7).

109 installer: https://archive.org/details/microsoft-edge-web-view-2-runtime-installer-v109.0.1518.78