pythonnet / pythonnet/clr-loader

RuntimeError: Failed to resolve Python.Runtime.Loader.Initialize from M:\development\releases\3.9.1\test_venv\lib\site-packages\pythonnet\runtime\Python.Runtime.dll

Aperta
#74 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
42
Fork
32
Merge medio
14h 1m
PR unite (30g)
1

Descrizione

I have mapped a network drive (assigned drive letter M) on my local machine, created a virtual environment on it and installed all the supporting libraries that are required to run my application. I get the Python runtime error when I try to import clr directly on virtual environment Python interpreter (located on M drive) console.

M:\development\releases\3.9.1\test_venv\Scripts>python
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import clr
Traceback (most recent call last):
File "", line 1, in
File "M:\development\releases\3.9.1\test_venv\lib\site-packages\clr.py", line 6, in
load()
File "M:\development\releases\3.9.1\test_venv\lib\site-packages\pythonnet_init_.py", line 143, in load
func = assembly.get_function("Python.Runtime.Loader.Initialize")
File "M:\development\releases\3.9.1\test_venv\lib\site-packages\clr_loader\types.py", line 94, in get_function
return ClrFunction(self._runtime, self._path, name, func)
File "M:\development\releases\3.9.1\test_venv\lib\site-packages\clr_loader\types.py", line 58, in init
self._callable = runtime._get_callable(assembly, typename, func_name)
File "M:\development\releases\3.9.1\test_venv\lib\site-packages\clr_loader\netfx.py", line 47, in _get_callable
raise RuntimeError(
RuntimeError: Failed to resolve Python.Runtime.Loader.Initialize from M:\development\releases\3.9.1\test_venv\lib\site-packages\pythonnet\runtime\Python.Runtime.dll

Upon more debugging, I noticed that the lib\site-packages\clr_loader\netfx.py module's pyclr_get_function function returns NULL on the shared drive (M). I'm not sure what exactly is missing on this M drive. But same virtual environment works fine on local drive.

print(f"Assembly Path: {str(Path(assembly_path))}")
print(f"Type Name: {typename}")
print(f"Function Name: {function}")
func = _FW.pyclr_get_function(
self._domain,
str(Path(assembly_path)).encode("utf8"),
typename.encode("utf8"),
function.encode("utf8"),
)
print("Returned Function:", func)

if func == ffi.NULL:
raise RuntimeError(
f"Failed to resolve {typename}.{function} from {assembly_path}"
)

Assembly Path: M:\development\releases\3.9.1\test_venv\lib\site-packages\pythonnet\runtime\Python.Runtime.dll
Type Name: Python.Runtime.Loader
Function Name: Initialize
Output: Returned Function: <cdata 'int(*)(void , int)' NULL>


If I create the same virtual environment on local drive (W:) and try to import clr, it just works fine.

(autobot_venv 3.9.1) W:\Projects\development\test_venv>python
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
**>>>

import clr
**

I see below output `by calling pyclr_get_function function from netfx.py module on local drive
Output: Returned Function: <cdata 'int()(void , int)' 0x0000022653BF407C>

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo import clr nell’ambiente virtuale sull’unità M e confrontalo con l’ambiente funzionante sull’unità W. Ispeziona lib\site-packages\clr_loader\netfx.py, in particolare pyclr_get_function, e il percorso segnalato di Python.Runtime.dll. Il lavoro è completato quando viene identificato il motivo per cui Python.Runtime.Loader.Initialize viene risolto localmente ma restituisce NULL sull’unità di rete, con una correzione riproducibile o una limitazione chiara.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.