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

オープン
#74 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
42
フォーク
32
平均マージ
14時間 1分
マージ済み PR(30日)
1

説明

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>

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、M ドライブの仮想環境で import clr を再現し、動作している W ドライブの環境と比較します。lib\site-packages\clr_loader\netfx.py、特に pyclr_get_function と、報告された Python.Runtime.dll のパスを調査します。Python.Runtime.Loader.Initialize がローカルでは解決される一方、ネットワークドライブでは NULL を返す理由を、再現可能な修正または明確な制限とともに特定できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。