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

briefcase run returns "Failed to create a default .NET runtime" #1017

Open
Matt8198 opened this issue Dec 25, 2022 · 16 comments
Open

briefcase run returns "Failed to create a default .NET runtime" #1017

Matt8198 opened this issue Dec 25, 2022 · 16 comments
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.

Comments

@Matt8198
Copy link

Matt8198 commented Dec 25, 2022

Describe the bug

Hi,

Following your tutorial, it failed when I used the “briefcase.exe run” command.
The create and build commands didn't fail. I can also use the briefcase dev command with no problems.

ModuleNotFoundError: No module named '_cffi_backend'
RuntimeError: Failed to create a default .NET runtime, which would
                    have been "netfx" on this system. Either install a
                    compatible runtime or configure it explicitly via
                    `set_runtime` or the `PYTHONNET_*` environment variables
                    (see set_runtime_from_env).
briefcase run log
(venv_teamcolo) PS C:\Users\matth\Documents\Teamcolo\teamcolo> briefcase.exe run --log

[teamcolo] Starting app...
===========================================================================
Log started: 2022-12-25 12:41:36Z
PreInitializing Python runtime...
PythonHome: C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src
PYTHONPATH:
- C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\python39.zip
- C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src
- C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages
- C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app
Configure argc/argv...
Initializing Python runtime...
Running app module: teamcolo
---------------------------------------------------------------------------
Traceback (most recent call last):
  File "\app_packages\pythonnet\__init__.py", line 73, in _create_runtime_from_spec
    return clr_loader.get_netfx(**params)
  File "\app_packages\clr_loader\__init__.py", line 146, in get_netfx
    from .netfx import NetFx
  File "\app_packages\clr_loader\netfx.py", line 5, in <module>
    from .ffi import ffi, load_netfx
  File "\app_packages\clr_loader\ffi\__init__.py", line 11, in <module>
    ffi = cffi.FFI()  # type: ignore
  File "\app_packages\cffi\api.py", line 48, in __init__
    import _cffi_backend as backend
ModuleNotFoundError: No module named '_cffi_backend'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "\app\teamcolo\__main__.py", line 4, in <module>
    main().main_loop()
  File "\app\teamcolo\app.py", line 41, in main
    return Teamcolo()
  File "\app_packages\toga\app.py", line 278, in __init__
    self.factory = get_platform_factory(factory)
  File "\app_packages\toga\platform.py", line 55, in get_platform_factory
    from toga_winforms import factory
  File "\app_packages\toga_winforms\factory.py", line 1, in <module>
    from .app import App, MainWindow
  File "\app_packages\toga_winforms\app.py", line 7, in <module>
    from .keys import toga_to_winforms_key
  File "\app_packages\toga_winforms\keys.py", line 6, in <module>
    from .libs import WinForms
  File "\app_packages\toga_winforms\libs\__init__.py", line 1, in <module>
    from .fonts import (  # noqa: F401
  File "\app_packages\toga_winforms\libs\fonts.py", line 13, in <module>
    from .winforms import (
  File "\app_packages\toga_winforms\libs\winforms.py", line 3, in <module>
    import clr
  File "\app_packages\clr.py", line 6, in <module>
    load()
  File "\app_packages\pythonnet\__init__.py", line 131, in load
    set_runtime_from_env()
  File "\app_packages\pythonnet\__init__.py", line 114, in set_runtime_from_env
    runtime = _create_runtime_from_spec(spec)
  File "\app_packages\pythonnet\__init__.py", line 82, in _create_runtime_from_spec
    raise RuntimeError(
RuntimeError: Failed to create a default .NET runtime, which would
                    have been "netfx" on this system. Either install a
                    compatible runtime or configure it explicitly via
                    `set_runtime` or the `PYTHONNET_*` environment variables
                    (see set_runtime_from_env).

---------------------------------------------------------------------------
Application quit abnormally (Exit code -6)!
Traceback (most recent call last):
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\pythonnet\__init__.py", line 73, in _create_runtime_from_spec
    return clr_loader.get_netfx(**params)
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\clr_loader\__init__.py", line 146, in get_netfx
    from .netfx import NetFx
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\clr_loader\netfx.py", line 5, in <module>
    from .ffi import ffi, load_netfx
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\clr_loader\ffi\__init__.py", line 11, in <module>
    ffi = cffi.FFI()  # type: ignore
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\cffi\api.py", line 48, in __init__
    import _cffi_backend as backend
ModuleNotFoundError: No module named '_cffi_backend'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "runpy.py", line 197, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app\teamcolo\__main__.py", line 4, in <module>
    main().main_loop()
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app\teamcolo\app.py", line 41, in main
    return Teamcolo()
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga\app.py", line 278, in __init__
    self.factory = get_platform_factory(factory)
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga\platform.py", line 55, in get_platform_factory
    from toga_winforms import factory
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\factory.py", line 1, in <module>
    from .app import App, MainWindow
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\app.py", line 7, in <module>
    from .keys import toga_to_winforms_key
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\keys.py", line 6, in <module>
    from .libs import WinForms
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\libs\__init__.py", line 1, in <module>
    from .fonts import (  # noqa: F401
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\libs\fonts.py", line 13, in <module>
    from .winforms import (
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\toga_winforms\libs\winforms.py", line 3, in <module>
    import clr
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\clr.py", line 6, in <module>
    load()
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\pythonnet\__init__.py", line 131, in load
    set_runtime_from_env()
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\pythonnet\__init__.py", line 114, in set_runtime_from_env
    runtime = _create_runtime_from_spec(spec)
  File "C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\app_packages\pythonnet\__init__.py", line 82, in _create_runtime_from_spec
    raise RuntimeError(
RuntimeError: Failed to create a default .NET runtime, which would
                    have been "netfx" on this system. Either install a
                    compatible runtime or configure it explicitly via
                    `set_runtime` or the `PYTHONNET_*` environment variables
                    (see set_runtime_from_env).

After some research, I tried to install the cffi package (after uninstalling it) in the environment, but also outside.
It didn't solve the problem.

I don't know if some people have already had this issue.

If you need more information, please ask me.

Steps to reproduce

  1. Run the briefcase create command
  2. Run the briefcase build command
  3. Run the briefcase run command

Expected behavior

No error returned.

Screenshots

No response

Environment

  • Operating System: Windows-10-10.0.22621
  • Python version: 3.9.8 (tags/v3.9.8:bb3fdcf, Nov 5 2021, 20:33:01) [MSC v.1929 32 bit (Intel)]
  • Software versions:
    • Briefcase: 0.3.11
    • toga-core: 0.3.0.dev39
    • toga-winforms: 0.3.0.dev39
    • cffi: 1.15.1
    • cryptography: 38.0.4
    • paramiko: 2.12.0

Logs

full briefcase run log
Date/Time:       2022-12-25 12:41:39 
Command line:    C:\Users\matth\Documents\Teamcolo\venv_teamcolo\Scripts\briefcase run --log

OS Release:      Windows 10
OS Version:      10.0.22621
Architecture:    AMD64
Platform:        Windows-10-10.0.22621

Python exe:      C:\Users\matth\Documents\Teamcolo\venv_teamcolo\Scripts\python.exe
Python version:  3.9.8 (tags/v3.9.8:bb3fdcf, Nov  5 2021, 20:33:01) [MSC v.1929 32 bit (Intel)]
Virtual env:     True
Conda env:       False

Briefcase:       0.3.11
Target platform: windows
Target format:   app

Environment Variables:
    ALLUSERSPROFILE=C:\ProgramData
    APPDATA=C:\Users\matth\AppData\Roaming
    CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\crashpad_36524_SHCGTZXMAMZCACZV
    CLION=D:\CLion 2019.2.4\bin;
    COLORTERM=truecolor
    COMMONPROGRAMFILES=C:\Program Files (x86)\Common Files
    COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
    COMMONPROGRAMW6432=C:\Program Files\Common Files
    COMPUTERNAME=PC-MATTHIAS
    COMSPEC=C:\WINDOWS\system32\cmd.exe
    CONFIGSETROOT=C:\WINDOWS\ConfigSetRoot
    DISQUE=D:\
    DRIVERDATA=C:\Windows\System32\Drivers\DriverData
    FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
    FPS_BROWSER_USER_PROFILE_STRING=Default
    GIT_ASKPASS=********************
    HOMEDRIVE=C:
    HOMEPATH=\Users\matth
    LANG=fr_FR.UTF-8
    LOCALAPPDATA=C:\Users\matth\AppData\Local
    LOGONSERVER=\\PC-MATTHIAS
    NUMBER_OF_PROCESSORS=12
    ONEDRIVE=C:\Users\matth\OneDrive
    ONEDRIVECONSUMER=C:\Users\matth\OneDrive
    ORIGINAL_XDG_CURRENT_DESKTOP=undefined
    OS=Windows_NT
    PATH=C:\Users\matth\Documents\Teamcolo\venv_teamcolo\Scripts;C:\Program Files (x86)\Python39-32\Scripts\;C:\Program Files (x86)\Python39-32\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Git\cmd;D:\Mingw-w64\mingw32\bin\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Matlab\runtime\win64;D:\Matlab\bin;D:\Matlab\polyspace\bin;C:\Program Files\Polyspace\R2019b\runtime\win64;C:\Program Files\Polyspace\R2019b\bin;C:\Program Files\Polyspace\R2019b\polyspace\bin;C:\Program Files\nodejs\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Git\cmd;C;C:\Program Files\usbipd-win\;C:\Program Files\PuTTY\;C:\Program Files\CMake\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Docker\Docker\resources\bin;C:\Users\matth\scoop\shims;C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin;C:\Users\matth\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\matth\AppData\Local\Programs\Python\Python37-32\;C:\Users\matth\AppData\Local\Microsoft\WindowsApps;D:\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\CLion 2019.2.4\bin;C:\Users\matth\AppData\Roaming\npm;C:\Users\matth\AppData\Local\GitHubDesktop\bin;C:\Program Files\Azure Data Studio\bin;C:\Users\matth\.dotnet\tools;C:\Users\matth\AppData\Local\Microsoft\WindowsApps;C:\Users\matth\.dotnet\tools
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.CPL
    PICO_SDK_PATH=C:\Users\matth\OneDrive\Documents\Pico\pico-sdk
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_ARCHITEW6432=AMD64
    PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=9e0a
    PROGRAMDATA=C:\ProgramData
    PROGRAMFILES=C:\Program Files (x86)
    PROGRAMFILES(X86)=C:\Program Files (x86)
    PROGRAMW6432=C:\Program Files
    PSMODULEPATH=C:\Users\matth\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\PowerShell\Modules\
    PUBLIC=C:\Users\Public
    SESSIONNAME=Console
    SYSTEMDRIVE=C:
    SYSTEMROOT=C:\WINDOWS
    TEMP=C:\Users\matth\AppData\Local\Temp
    TERM_PROGRAM=vscode
    TERM_PROGRAM_VERSION=1.73.1
    TMP=C:\Users\matth\AppData\Local\Temp
    USERDOMAIN=PC-MATTHIAS
    USERDOMAIN_ROAMINGPROFILE=PC-MATTHIAS
    USERNAME=matth
    USERPROFILE=C:\Users\matth
    VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
    VIRTUAL_ENV=C:\Users\matth\Documents\Teamcolo\venv_teamcolo
    VSCODE_GIT_ASKPASS_EXTRA_ARGS=********************
    VSCODE_GIT_ASKPASS_MAIN=********************
    VSCODE_GIT_ASKPASS_NODE=********************
    VSCODE_GIT_IPC_HANDLE=\\.\pipe\vscode-git-3e2ea1f4c3-sock
    WINDIR=C:\WINDOWS
    ZES_ENABLE_SYSMAN=1
    _OLD_VIRTUAL_PATH=C:\Program Files (x86)\Python39-32\Scripts\;C:\Program Files (x86)\Python39-32\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Git\cmd;D:\Mingw-w64\mingw32\bin\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Matlab\runtime\win64;D:\Matlab\bin;D:\Matlab\polyspace\bin;C:\Program Files\Polyspace\R2019b\runtime\win64;C:\Program Files\Polyspace\R2019b\bin;C:\Program Files\Polyspace\R2019b\polyspace\bin;C:\Program Files\nodejs\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Git\cmd;C;C:\Program Files\usbipd-win\;C:\Program Files\PuTTY\;C:\Program Files\CMake\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Docker\Docker\resources\bin;C:\Users\matth\scoop\shims;C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin;C:\Users\matth\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\matth\AppData\Local\Programs\Python\Python37-32\;C:\Users\matth\AppData\Local\Microsoft\WindowsApps;D:\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\CLion 2019.2.4\bin;C:\Users\matth\AppData\Roaming\npm;C:\Users\matth\AppData\Local\GitHubDesktop\bin;C:\Program Files\Azure Data Studio\bin;C:\Users\matth\.dotnet\tools;C:\Users\matth\AppData\Local\Microsoft\WindowsApps;C:\Users\matth\.dotnet\tools

Briefcase Log:
[12:41:36]                                                                                                                                                            __init__.py:82
           [teamcolo] Starting app...                                                                                                                                 __init__.py:82
           ===========================================================================                                                                                __init__.py:85
                                                                                                                                                                   subprocess.py:516
           >>> Running Command:                                                                                                                                    subprocess.py:517
           >>>     'C:\Users\matth\Documents\Teamcolo\teamcolo\windows\app\Teamcolo\src\Teamcolo.exe'                                                              subprocess.py:518
           >>> Working Directory:                                                                                                                                  subprocess.py:525
           >>>     C:\Users\matth                                                                                                                                  subprocess.py:526
[12:41:39] >>> Return code: 1                                                                                                                                      subprocess.py:553
                                                                                                                                                                      __main__.py:27
           Unable to start app teamcolo.                                                                                                                              __main__.py:28

╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────╮
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\platforms\windows\__init__.py:86 in run_app                                                          │
│                                                                                                                                                                                  │
│    83 │   │   try:                                                                                                                                                               │
│    84 │   │   │   # Start streaming logs for the app.                                                                                                                            │
│    85 │   │   │   self.logger.info("=" * 75)                                                                                                                                     │
│ ❱  86 │   │   │   self.tools.subprocess.run(                                                                                                                                     │
│    87 │   │   │   │   [os.fsdecode(self.binary_path(app))],                                                                                                                      │
│    88 │   │   │   │   cwd=self.tools.home_path,                                                                                                                                  │
│    89 │   │   │   │   check=True,                                                                                                                                                │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────── locals ───────────────────────────────────────╮                                                                                         │
│ │    app = <com.example.teamcolo v0.0.1 AppConfig>                                     │                                                                                         │
│ │ kwargs = {}                                                                          │                                                                                         │
│ │   self = <briefcase.platforms.windows.app.WindowsAppRunCommand object at 0x0230EAC0> │                                                                                         │
│ ╰──────────────────────────────────────────────────────────────────────────────────────╯                                                                                         │
│                                                                                                                                                                                  │
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\integrations\subprocess.py:110 in inner                                                              │
│                                                                                                                                                                                  │
│   107 │   │   """                                                                                                                                                                │
│   108 │   │   # Just run the command if no dynamic elements are active                                                                                                           │
│   109 │   │   if not sub.tools.input.is_console_controlled:                                                                                                                      │
│ ❱ 110 │   │   │   return sub_method(sub, args, **kwargs)                                                                                                                         │
│   111 │   │                                                                                                                                                                      │
│   112 │   │   remove_dynamic_elements = False                                                                                                                                    │
│   113                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭────────────────────────────────────────────────── locals ───────────────────────────────────────────────────╮                                                                  │
│ │       args = ['C:\\Users\\matth\\Documents\\Teamcolo\\teamcolo\\windows\\app\\Teamcolo\\src\\Teamcolo.exe'] │                                                                  │
│ │     kwargs = {'cwd': WindowsPath('C:/Users/matth'), 'check': True, 'stream_output': True}                   │                                                                  │
│ │        sub = <briefcase.integrations.subprocess.Subprocess object at 0x049701A8>                            │                                                                  │
│ │ sub_method = <function Subprocess.run at 0x048BF418>                                                        │                                                                  │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                  │
│                                                                                                                                                                                  │
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\integrations\subprocess.py:284 in run                                                                │
│                                                                                                                                                                                  │
│   281 │   │   if stream_output or (                                                                                                                                              │
│   282 │   │   │   self.tools.input.is_console_controlled and not is_output_redirected                                                                                            │
│   283 │   │   ):                                                                                                                                                                 │
│ ❱ 284 │   │   │   return self._run_and_stream_output(args, **kwargs)                                                                                                             │
│   285 │   │                                                                                                                                                                      │
│   286 │   │   # Otherwise, invoke run() normally.                                                                                                                                │
│   287 │   │   self._log_command(args)                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────╮                                                        │
│ │                 args = ['C:\\Users\\matth\\Documents\\Teamcolo\\teamcolo\\windows\\app\\Teamcolo\\src\\Teamcolo.exe'] │                                                        │
│ │ is_output_redirected = None                                                                                           │                                                        │
│ │               kwargs = {'cwd': WindowsPath('C:/Users/matth'), 'check': True}                                          │                                                        │
│ │                 self = <briefcase.integrations.subprocess.Subprocess object at 0x049701A8>                            │                                                        │
│ │        stream_output = True                                                                                           │                                                        │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                        │
│                                                                                                                                                                                  │
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\integrations\subprocess.py:350 in _run_and_stream_output                                             │
│                                                                                                                                                                                  │
│   347 │   │   self._log_return_code(return_code)                                                                                                                                 │
│   348 │   │                                                                                                                                                                      │
│   349 │   │   if check and return_code:                                                                                                                                          │
│ ❱ 350 │   │   │   raise subprocess.CalledProcessError(return_code, args, stderr=stderr)                                                                                          │
│   351 │   │                                                                                                                                                                      │
│   352 │   │   return subprocess.CompletedProcess(args, return_code, stderr=stderr)                                                                                               │
│   353                                                                                                                                                                            │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────────────────── locals ───────────────────────────────────────────────────╮                                                                 │
│ │        args = ['C:\\Users\\matth\\Documents\\Teamcolo\\teamcolo\\windows\\app\\Teamcolo\\src\\Teamcolo.exe'] │                                                                 │
│ │       check = True                                                                                           │                                                                 │
│ │      kwargs = {'cwd': WindowsPath('C:/Users/matth'), 'stdout': -1, 'stderr': -2, 'bufsize': 1}               │                                                                 │
│ │     process = <Popen: returncode: 1 args: ['C:\\Users\\matth\\Documents\\Teamcolo\\teamcol...>               │                                                                 │
│ │ return_code = 1                                                                                              │                                                                 │
│ │        self = <briefcase.integrations.subprocess.Subprocess object at 0x049701A8>                            │                                                                 │
│ │      stderr = None                                                                                           │                                                                 │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
CalledProcessError: Command '['C:\\Users\\matth\\Documents\\Teamcolo\\teamcolo\\windows\\app\\Teamcolo\\src\\Teamcolo.exe']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

╭─────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────╮
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\__main__.py:21 in main                                                                               │
│                                                                                                                                                                                  │
│   18 │   │   options = command.parse_options(extra=extra_cmdline)                                                                                                                │
│   19 │   │   command.check_obsolete_data_dir()                                                                                                                                   │
│   20 │   │   command.parse_config(Path.cwd() / "pyproject.toml")                                                                                                                 │
│ ❱ 21 │   │   command(**options)                                                                                                                                                  │
│   22 │   except HelpText as e:                                                                                                                                                   │
│   23 │   │   logger.info()                                                                                                                                                       │
│   24 │   │   logger.info(str(e))                                                                                                                                                 │
│                                                                                                                                                                                  │
│ ╭────────────────────────────────────────── locals ───────────────────────────────────────────╮                                                                                  │
│ │       command = <briefcase.platforms.windows.app.WindowsAppRunCommand object at 0x0230EAC0> │                                                                                  │
│ │       Command = <class 'briefcase.platforms.windows.app.WindowsAppRunCommand'>              │                                                                                  │
│ │       console = <briefcase.console.Console object at 0x02526B68>                            │                                                                                  │
│ │             e = BriefcaseCommandError('Unable to start app teamcolo.')                      │                                                                                  │
│ │ extra_cmdline = ['--log']                                                                   │                                                                                  │
│ │        logger = <briefcase.console.Log object at 0x023BE628>                                │                                                                                  │
│ │       options = {'appname': None, 'update': False}                                          │                                                                                  │
│ │        result = 200                                                                         │                                                                                  │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────╯                                                                                  │
│                                                                                                                                                                                  │
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\commands\run.py:68 in __call__                                                                       │
│                                                                                                                                                                                  │
│   65 │   │                                                                                                                                                                       │
│   66 │   │   self.verify_app_tools(app)                                                                                                                                          │
│   67 │   │                                                                                                                                                                       │
│ ❱ 68 │   │   state = self.run_app(app, **full_options(state, options))                                                                                                           │
│   69 │   │                                                                                                                                                                       │
│   70 │   │   return state                                                                                                                                                        │
│   71                                                                                                                                                                             │
│                                                                                                                                                                                  │
│ ╭──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮                                                              │
│ │           app = <com.example.teamcolo v0.0.1 AppConfig>                                                         │                                                              │
│ │       appname = None                                                                                            │                                                              │
│ │   binary_file = WindowsPath('C:/Users/matth/Documents/Teamcolo/teamcolo/windows/app/Teamcolo/src/Teamcolo.exe') │                                                              │
│ │       options = {}                                                                                              │                                                              │
│ │          self = <briefcase.platforms.windows.app.WindowsAppRunCommand object at 0x0230EAC0>                     │                                                              │
│ │         state = None                                                                                            │                                                              │
│ │ template_file = WindowsPath('C:/Users/matth/Documents/Teamcolo/teamcolo/windows/app/Teamcolo')                  │                                                              │
│ │        update = False                                                                                           │                                                              │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                              │
│                                                                                                                                                                                  │
│ C:\Users\matth\Documents\Teamcolo\venv_teamcolo\lib\site-packages\briefcase\platforms\windows\__init__.py:93 in run_app                                                          │
│                                                                                                                                                                                  │
│    90 │   │   │   │   stream_output=True,                                                                                                                                        │
│    91 │   │   │   )                                                                                                                                                              │
│    92 │   │   except subprocess.CalledProcessError as e:                                                                                                                         │
│ ❱  93 │   │   │   raise BriefcaseCommandError(f"Unable to start app {app.app_name}.") from e                                                                                     │
│    94                                                                                                                                                                            │
│    95                                                                                                                                                                            │
│    96 class WindowsPackageCommand(PackageCommand):                                                                                                                               │
│                                                                                                                                                                                  │
│ ╭─────────────────────────────────────── locals ───────────────────────────────────────╮                                                                                         │
│ │    app = <com.example.teamcolo v0.0.1 AppConfig>                                     │                                                                                         │
│ │ kwargs = {}                                                                          │                                                                                         │
│ │   self = <briefcase.platforms.windows.app.WindowsAppRunCommand object at 0x0230EAC0> │                                                                                         │
│ ╰──────────────────────────────────────────────────────────────────────────────────────╯                                                                                         │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
BriefcaseCommandError: Unable to start app teamcolo.

Additional context

No response

Workaround

The issue occurs when running 32-bit Python. Install and use Briefcase with 64-bit Python. Full details.

@Matt8198 Matt8198 added the bug A crash or error in behavior. label Dec 25, 2022
@freakboy3742
Copy link
Member

Thanks for the report. I can't say I've seen this behaviour myself; Can I ask what (if any) .NET libraries you have installed on your system? I didn't think it was necessary to install a .NET runtime for Python.net to work... but maybe it is required?

@coolcoder613eb
Copy link

i have this problem on win10 with py311

@freakboy3742
Copy link
Member

@coolcoder613eb That doesn't address the most recent question that I asked - What (if any) .NET libraries do you have installed?

@coolcoder613eb
Copy link

coolcoder613eb commented Jan 11, 2023 via email

@freakboy3742
Copy link
Member

@coolcoder613eb Symlinking site packages across Python versions is not an approach that is likely to yield reliable results. It's entirely possible that you've created this problem on your own.

If you can reproduce the problem with a vanilla installation, then please provide the briefcase crash log, as well as the detail I've requested about .NET.

@CarlosHGL
Copy link

CarlosHGL commented Jan 24, 2023

[Moved to #1060]

@rmartin16
Copy link
Member

@CarlosHGL, can you take a look at #922 and see if one of the workarounds help you finish the build? I don't see anything obviously wrong but I can see you are using Python from the Windows Store.

@mhsmith
Copy link
Member

mhsmith commented Jan 24, 2023

@rmartin16: This looks like a different problem, so I've moved it to a separate issue (#1060).

@mhsmith mhsmith changed the title The briefcase run command always returns error briefcase dev works, but briefcase run returns "Failed to create a default .NET runtime" Jan 24, 2023
@mhsmith mhsmith added the windows The issue relates to Microsoft Windows support. label Jan 24, 2023
@mhsmith mhsmith changed the title briefcase dev works, but briefcase run returns "Failed to create a default .NET runtime" briefcase run returns "Failed to create a default .NET runtime" Jan 24, 2023
@freakboy3742 freakboy3742 added the awaiting details More details are needed before the issue can be triaged. label Jan 24, 2023
@freakboy3742
Copy link
Member

@jlij No - because we've been waiting on someone to provide the detail that has been requested. What (if any) .NET libraries do you have installed on your system when you observe this problem?

@rmartin16
Copy link
Member

rmartin16 commented Jun 6, 2023

This issue seems to stem from using a 32bit version of Python to run briefcase run. This conflicts somehow with the stub app running the embedded Python (which is 64bit) and loading the CLR through Python.NET.

Python will include its bitness when running the interpreter:

32 bit

python
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:34:50) [MSC v.1934 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

64 bit

python
Python 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Therefore, the workaround is to use a 64 bit version of Python to run Briefcase.

@rmartin16
Copy link
Member

After a little more investigation, the underlying problem is the the 32bit Windows wheel for cffi is being installed when using 32bit Python.

[helloworld] Updating requirements...

>>> Running Command:
>>>     'C:\Users\user\github\beeware\briefcase\venv-3.11-win32-briefcase\Scripts\python.exe' -u -m pip install --upgrade --no-user '--target=C:\Users\user\github\beeware\briefcase\tmp\helloworld\build\helloworld\windows\visualstudio\x64\Release\app_packages' 'toga-winforms~=0.3.1'
>>> Working Directory:
>>>     C:\Users\user\github\beeware\briefcase\tmp\helloworld
>>> Environment Overrides:
>>>     PYTHONPATH=C:\Users\user\github\beeware\briefcase\tmp\helloworld\build\helloworld\windows\visualstudio\x64\Release\platform-site
Collecting toga-winforms~=0.3.1
  Using cached toga_winforms-0.3.1-py3-none-any.whl (328 kB)
Collecting pythonnet>=3.0.0 (from toga-winforms~=0.3.1)
  Using cached pythonnet-3.0.1-py3-none-any.whl (284 kB)
Collecting toga-core==0.3.1 (from toga-winforms~=0.3.1)
  Using cached toga_core-0.3.1-py3-none-any.whl (499 kB)
Collecting travertino>=0.1.3 (from toga-core==0.3.1->toga-winforms~=0.3.1)
  Using cached travertino-0.2.0-py3-none-any.whl (16 kB)
Collecting clr-loader<0.3.0,>=0.2.2 (from pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached clr_loader-0.2.5-py3-none-any.whl (51 kB)
Collecting cffi>=1.13 (from clr-loader<0.3.0,>=0.2.2->pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached cffi-1.15.1-cp311-cp311-win32.whl (170 kB)
Collecting pycparser (from cffi>=1.13->clr-loader<0.3.0,>=0.2.2->pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: travertino, pycparser, toga-core, cffi, clr-loader, pythonnet, toga-winforms
Successfully installed cffi-1.15.1 clr-loader-0.2.5 pycparser-2.21 pythonnet-3.0.1 toga-core-0.3.1 toga-winforms-0.3.1 travertino-0.2.0
>>> Return code: 0
Installing app requirements... done

Since the stub app is compiled for 64 bits, we need the 64 bit version of cffi to be installed so it can find and load the .NET Framework at runtime.

Pip supports overriding how it requests wheels such that wheels for arbitrary platforms can be installed. Something like this in WindowsCreateCommand would achieve that here:

    def _extra_pip_args(self, app: AppConfig):
        return ["--platform", "win_amd64", "--only-binary", ":all:"]
>>> Running Command:
>>>     'C:\Users\user\github\beeware\briefcase\venv-3.11-win32-briefcase\Scripts\python.exe' -u -m pip install --upgrade --no-user '--target=C:\Users\user\github\beeware\briefcase\tmp\helloworld\build\helloworld\windows\visualstudio\x64\Release\app_packages' --platform win_amd64 --only-binary :all: 'toga-winforms~=0.3.1'
>>> Working Directory:
>>>     C:\Users\user\github\beeware\briefcase\tmp\helloworld
>>> Environment Overrides:
>>>     PYTHONPATH=C:\Users\user\github\beeware\briefcase\tmp\helloworld\build\helloworld\windows\visualstudio\x64\Release\platform-site
Collecting toga-winforms~=0.3.1
  Using cached toga_winforms-0.3.1-py3-none-any.whl (328 kB)
Collecting pythonnet>=3.0.0 (from toga-winforms~=0.3.1)
  Using cached pythonnet-3.0.1-py3-none-any.whl (284 kB)
Collecting toga-core==0.3.1 (from toga-winforms~=0.3.1)
  Using cached toga_core-0.3.1-py3-none-any.whl (499 kB)
Collecting travertino>=0.1.3 (from toga-core==0.3.1->toga-winforms~=0.3.1)
  Using cached travertino-0.2.0-py3-none-any.whl (16 kB)
Collecting clr-loader<0.3.0,>=0.2.2 (from pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached clr_loader-0.2.5-py3-none-any.whl (51 kB)
Collecting cffi>=1.13 (from clr-loader<0.3.0,>=0.2.2->pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached cffi-1.15.1-cp311-cp311-win_amd64.whl (179 kB)
Collecting pycparser (from cffi>=1.13->clr-loader<0.3.0,>=0.2.2->pythonnet>=3.0.0->toga-winforms~=0.3.1)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: travertino, pycparser, toga-core, cffi, clr-loader, pythonnet, toga-winforms
Successfully installed cffi-1.15.1 clr-loader-0.2.5 pycparser-2.21 pythonnet-3.0.1 toga-core-0.3.1 toga-winforms-0.3.1 travertino-0.2.0
>>> Return code: 0
Installing app requirements... done

Additionally, pip insists on a setting for binary or not:

[helloworld] Updating requirements...
ERROR: When restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).
Installing app requirements...

@freakboy3742
Copy link
Member

So - this is all good diagnosis, but... how much do we care? How big is the market for 32-bit Windows these days? If these metrics are to be believed, the size of the 32 bit Windows market is 0 within the margin of error. Given that we can't unit test 32 bit Windows (AFAIK), wouldn't our safe option be to just raise an error if the user is on a 32 bit system and move on?

@rmartin16
Copy link
Member

This isn't about 32bit Windows, though. This is about 32bit Python.

@freakboy3742
Copy link
Member

Sure - but... same story. Is there any good reason someone is using 32-bit Python on a 64-bit system, other than "it exists and I didn't know there was an alternative, I just downloaded the first installer I saw on the list"? Finding market share numbers for 32-bit Python is a little harder to come by, but I can't really think of a reason anyone would be actively using 32-bit Windows on a 32 bit system, other than legacy.

@rmartin16
Copy link
Member

We're definitely on the same page about support for 32-bit Windows.

As for 32-bit Python, I doubt there's any broad and/or reasonable rationale to run it nowadays....maybe someone needs to use a package that's only 32-bit compatible....but I don't think that's a good rationale to impact our decisions here.

Mostly, I would expect people running 32-bit Python to be doing so largely arbitrarily. It wasn't until Python 3.9, that python.org pushed 64-bit as the default download.

Ultimately, I'm not necessarily advocating for supporting 32-bit Python. And since I've already been evaluating how to limit Briefcase to only running commands on supported architectures, this check would add another layer...albeit only really for Windows. This also would ideally allow Windows on arm64 to still work...personally, I think Windows on ARM may see a real uptake in the next few years (or longer) but we'll see...

And then there's 32-bit ARM...but I'll spare us here :)

At the end of the day, I'm definitely not interested in a bunch of complications to support these niche platform combinations. But I think I'd also like to see some of them work if it doesn't take too much work. (Speaking of which, my proposed solution in the diagnosis would complicate arm64 support...)

If I do anything here, it'll likely be a part of the larger architecture verification I've been looking at.

@rmartin16
Copy link
Member

Somewhat of a proxy metric for 32-bit Python on Windows.

@rmartin16 rmartin16 removed the awaiting details More details are needed before the issue can be triaged. label Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. windows The issue relates to Microsoft Windows support.
Projects
None yet
Development

No branches or pull requests

6 participants