pythonnet icon indicating copy to clipboard operation
pythonnet copied to clipboard

Can I set the CoreCLR version?

Open Jason5Lee opened this issue 1 year ago • 3 comments

I'm trying to use pythonnet with .NET 9 RC. When I tried pythonnet.load("coreclr"), the following error message from .NET was shown.

You must install or update .NET to run this application.

App: <python path>
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64)
.NET location: <dotnet path>

The following frameworks were found:
  6.0.33 at [<path>]
  8.0.8 at [<path>]
  9.0.0-rc-1.24431.7 at [<path>]

...

It seems that .NET cannot resolve 9.0.0 with 9.0.0-rc. For my usecase 8.0.8 is OK. Can I make pythonnet to use this version of .NET?

Jason5Lee avatar Sep 27 '24 06:09 Jason5Lee

The function this is failing in is https://github.com/pythonnet/clr-loader/blob/master/clr_loader/init.py#L89

Is this really the only output you are seeing? There should at least be an exception message after this...

filmor avatar Sep 27 '24 08:09 filmor

I have the similar issue on two Windows 11 machines (In my case it's .net8 solution but requested by pythonnet is .net9): 'python.exe' (Win32): Loaded 'C:\Python311\python.exe'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 'python.exe' (Win32): Loaded 'C:\Python311\vcruntime140.dll'. 'python.exe' (Win32): Loaded 'C:\Python311\python311.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 'python.exe' (Win32): Loaded 'C:\Program Files\Avecto\Privilege Guard Client\PGHook.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. 'python.exe' (Win32): Loaded 'C:\Python311\python3.dll'. 'python.exe' (Win32): Loaded 'C:\Python311\DLLs_bz2.pyd'. 'python.exe' (Win32): Loaded 'C:\Python311\DLLs_lzma.pyd'. 'python.exe' (Win32): Loaded 'C:\Python311\Lib\site-packages_cffi_backend.cp311-win_amd64.pyd'. Module was built without symbols. 'python.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\psapi.dll'. 'python.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. 'python.exe' (Win32): Loaded 'C:\Program Files\dotnet\host\fxr\8.0.8\hostfxr.dll'. You must install or update .NET to run this application.

App: C:\Python311\python.exe Architecture: x64Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64).NET location: C:\Program Files\dotnet The following frameworks were found: 3.1.24 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 6.0.33 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 7.0.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 7.0.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 8.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 8.0.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 9.0.0-preview.7.24405.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 9.0.0-rc.1.24431.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Learn more: https://aka.ms/dotnet/app-launch-failed

To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=9.0.0&arch=x64&rid=win-x64&os=win10'python.exe' (Win32): Unloaded 'C:\Program Files\dotnet\host\fxr\8.0.8\hostfxr.dll'

PawelOHV avatar Oct 02 '24 09:10 PawelOHV

Please do not use the load("coreclr") and try: from clr_loader import get_coreclr from pythonnet import set_runtime

rt = get_coreclr(runtime_config="runtimeconfig.json") set_runtime(rt)

In the runtimeconfig.json replace with your framework { "runtimeOptions": { "tfm": "net8.0", "framework": { "name": "Microsoft.NETCore.App", "version": "8.0.8" } } }

PawelOHV avatar Oct 07 '24 09:10 PawelOHV