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

Abierto
#74 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
42
Forks
32
Merge medio
14 h 1 min
PR fusionados (30 d)
1

Descripción

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>

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza reproduciendo import clr en el entorno virtual de la unidad M y compáralo con el entorno funcional de la unidad W. Inspecciona lib\site-packages\clr_loader\netfx.py, especialmente pyclr_get_function, y la ruta indicada de Python.Runtime.dll. Se considera terminado cuando se identifique por qué Python.Runtime.Loader.Initialize se resuelve localmente, pero devuelve NULL en la unidad de red, con una solución reproducible o una limitación clara.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.