pangao1990 / PPX

基于Python和JavaScript,一键生成macOS、Windows和Linux平台客户端应用程序
https://blog.pangao.vip/docs-ppx/
GNU Affero General Public License v3.0
232 stars 39 forks source link

运行异常-虚拟环境问题 #3

Closed Boris-code closed 1 year ago

Boris-code commented 2 years ago

以下异常是虚拟环境下运行报错,正常环境下可以运行

[pywebview] EdgeHTML is deprecated. See https://pywebview.flowrl.com/guide/renderer.html#web-engine on details how to use Edge Chromium

未经处理的异常:  System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 System.Windows.Forms.Control.get_CacheTextInternal()
   在 System.Windows.Forms.Control.get_Text()
   在 System.Windows.Forms.Control.set_Text(String value)
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 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()
pangao1990 commented 2 years ago

根据报错信息来看,你的虚拟环境是不是没有满足以下条件?或者是你的虚拟机差点什么支持pywebview运行的程序呢?

image
Boris-code commented 2 years ago

完整的日志

npm run start

> vue-pywebview-pyinstaller@1.0.1 start
> vite build && run-script-os

vite v2.8.6 building for production...
✓ 16 modules transformed.
dist/assets/vue.03d6d6da.png           6.69 KiB
dist/assets/pywebview.94b84743.png     11.90 KiB
dist/assets/pyinstaller.77ebb35d.png   67.67 KiB
dist/index.html                        0.48 KiB
dist/assets/index.721823aa.js          2.25 KiB / gzip: 1.21 KiB
dist/assets/index.011be74b.css         0.28 KiB / gzip: 0.22 KiB
dist/assets/vendor.0c7feb7f.js         50.37 KiB / gzip: 20.23 KiB

> vue-pywebview-pyinstaller@1.0.1 start:windows
> .\pyenv\pyenv\Scripts\python -X dev .\pyapp\main.py

[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Runtime Registry path: Computer\HKEY_CURRENT_USER\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Beta Registry path: Computer\HKEY_CURRENT_USER\Microsoft\EdgeUpdate\Clients\{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Beta Registry path: Computer\HKEY_LOCAL_MACHINE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{2CD8A007-E189-409D-A2C8-9AF4EF3C72AA}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Developer Registry path: Computer\HKEY_CURRENT_USER\Microsoft\EdgeUpdate\Clients\{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Developer Registry path: Computer\HKEY_LOCAL_MACHINE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{0D50BFEC-CD6A-4F9A-964C-C7416E3ACB10}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Canary Registry path: Computer\HKEY_CURRENT_USER\Microsoft\EdgeUpdate\Clients\{65C35B14-6C1D-4122-AC46-7148CC9D6497}
[pywebview] [WinError 2] 系统找不到指定的文件。 - Microsoft Edge WebView2 Canary Registry path: Computer\HKEY_LOCAL_MACHINE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{65C35B14-6C1D-4122-AC46-7148CC9D6497}
[pywebview] EdgeHTML is deprecated. See https://pywebview.flowrl.com/guide/renderer.html#web-engine on details how to use Edge Chromium
Windows fatal exception: access violation

Current thread 0x00006f8c (most recent call first):
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyenv\pyenv\lib\site-packages\webview\platforms\winforms.py", line 166 in __init__
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyenv\pyenv\lib\site-packages\webview\platforms\winforms.py", line 488 in create

Thread 0x000053b8 (most recent call first):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\selectors.py", line 315 in _select
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\selectors.py", line 324 in select
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\socketserver.py", line 232 in serve_forever
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910 in run
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973 in _bootstrap_inner
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\threading.py", line 930 in _bootstrap

Thread 0x000047d8 (most recent call first):
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyenv\pyenv\lib\site-packages\webview\platforms\winforms.py", line 516 in create_window
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyenv\pyenv\lib\site-packages\webview\__init__.py", line 140 in start
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyapp\main.py", line 38 in WebViewApp
  File "C:\Users\Administrator\Desktop\vue-pywebview-pyinstaller-master\pyapp\main.py", line 43 in <module>

未经处理的异常:  System.NullReferenceException: 未将对象引用设置到对象的实例。
   在 System.Windows.Forms.Control.get_CacheTextInternal()
   在 System.Windows.Forms.Control.get_Text()
   在 System.Windows.Forms.Control.set_Text(String value)
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 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()

是虚拟环境下 EdgeHtml没找到?

pangao1990 commented 2 years ago

是的,你的虚拟环境没有webview2,可以安装一下。 EdgeWebView2Runtime的下载地址是 https://developer.microsoft.com/en-us/microsoft-edge/webview2/

image
Boris-code commented 2 years ago

感谢大佬耐心回答, 虚拟环境里不知道咋装这玩意,正常环境下是安装过了,可以跑起来。虚拟环境下 cef模式也跑不起来了

Boris-code commented 2 years ago

venv虚拟环境换成 virtualenv可以解决

pangao1990 commented 2 years ago

你说的是venv呀,我以为你说的虚拟环境是指虚拟机虚拟出一个新系统呢。我平时用的时候,觉得venv和virtualenv没啥区别。虽然venv是virtualenv集成到标准库中的子集,理论上来说venv功能会比virtualenv少一些。但是我平时使用并没有发现有啥不一样的。不过,你倒是发现了他们的不同,还是你厉害啊

Boris-code commented 2 years ago

哈哈,瞎试呗,没啥,还是大佬你厉害

pangao1990 commented 2 years ago

商业互吹一波~😄😄😄

WnagoiYy commented 1 year ago

venv虚拟环境换成 virtualenv可以解决

怎么替换呢,我也报这个错误了

WnagoiYy commented 1 year ago

@pangao1990 @Boris-code 解决了,更新下依赖,.\pyapp\assets\requirements.txt: pywebview==3.6.2 --> pywebview==3.7.2

最后查到问题在3.6.3和3.7版本中修复,pywebview 更新日志 - pyup.io https://pyup.io/packages/pypi/pywebview/changelog

pangao1990 commented 1 year ago

解决了,更新下依赖,.\pyapp\assets\requirements.txt: pywebview==3.6.2 --> pywebview==3.7.2

最后查到问题在3.6.3和3.7版本中修复,pywebview 更新日志 - pyup.io https://pyup.io/packages/pypi/pywebview/changelog

@WnagoiYy 不愧是大佬啊,我已经更新了pywebview的版本号。🙏🙏🙏

WnagoiYy commented 1 year ago

@WnagoiYy 不愧是大佬啊,我已经更新了pywebview的版本号。🙏🙏🙏

谦虚谦虚,你才是大佬,我是个菜鸡。

还有个打包cef的错误完全没头绪(借楼发一下,不开新issue了):

33868 INFO: Executing - upx --lzma -q C:\Users\99549\AppData\Local\pyinstaller\bincache01_py38_64bit\libcef.dll Traceback (most recent call last): File "E:\Miniconda3\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "E:\Miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\Scripts\pyinstaller.exe__main.py", line 7, in File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller__main__.py", line 124, in run run_build(pyi_config, spec_file, **vars(args)) File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\main.py", line 58, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\build_main.py", line 803, in main build(specfile, distpath, workpath, clean_build) File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\build_main.py", line 725, in build exec(code, spec_namespace) File ".\pyapp\spec\windows-cef.spec", line 50, in exe = EXE(pyz, File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\api.py", line 492, in init self.pkg = PKG( File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\api.py", line 206, in init self.postinit() File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\datastruct.py", line 155, in postinit__ self.assemble() File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\api.py", line 269, in assemble fnm = checkCache( File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\building\utils.py", line 351, in checkCache compat.exec_command(*cmd) File "E:\Project\Test\vue-pywebview-pyinstaller\pyenv\pyenvCEF\lib\site-packages\PyInstaller\compat.py", line 367, in exec_command out = proc.communicate(timeout=60)[0] File "E:\Miniconda3\lib\subprocess.py", line 1028, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "E:\Miniconda3\lib\subprocess.py", line 1401, in _communicate raise TimeoutExpired(self.args, orig_timeout) subprocess.TimeoutExpired: Command '('upx', '--lzma', '-q', 'C:\Users\99549\AppData\Local\pyinstaller\bincache01_py38_64bit\libcef.dll')' timed out after 60 seconds

pangao1990 commented 1 year ago

@WnagoiYy 你好,从这个报错信息来看,我不确定是 upx 这个压缩工具出问题了,还是打包过程中的cefpython3缺失libcef.dll了。不过,我又更新了一版vue-pywebview-pyinstaller,修复了一些pyinstaller打包过程中丢失cefpython3动态链接库的问题,你可以下载新版试试看。

WnagoiYy commented 1 year ago

@WnagoiYy 你好,从这个报错信息来看,我不确定是 upx 这个压缩工具出问题了,还是打包过程中的cefpython3缺失libcef.dll了。不过,我又更新了一版vue-pywebview-pyinstaller,修复了一些pyinstaller打包过程中丢失cefpython3动态链接库的问题,你可以下载新版试试看。

厉害厉害【牛!】,cef能build成功了。我提了个HMR的pr,大佬可以考虑引入一下,要是能解决更新py文件不重启也能hmr就更好了

pangao1990 commented 1 year ago

@WnagoiYy 你好,从这个报错信息来看,我不确定是 upx 这个压缩工具出问题了,还是打包过程中的cefpython3缺失libcef.dll了。不过,我又更新了一版vue-pywebview-pyinstaller,修复了一些pyinstaller打包过程中丢失cefpython3动态链接库的问题,你可以下载新版试试看。

厉害厉害【牛!】,cef能build成功了。我提了个HMR的pr,大佬可以考虑引入一下,要是能解决更新py文件不重启也能hmr就更好了

好的,我看看,然后合并一下代码。🐮🐮🐮