質問編集履歴
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,35 +1,4 @@
|
|
1
|
-
使用言語:C#
|
2
|
-
|
1
|
+
大変申し訳ありません。
|
3
|
-
|
2
|
+
少し考えれば気付けたと思うのですが、
|
4
|
-
Pythonnetのバージョン:2.5.1
|
5
|
-
|
6
|
-
C#にてPythonnetを用いて下記のようにPythonコードを実行しようとしたところ、.pyファイルImport時に例外エラーが発生しました。
|
7
|
-
|
3
|
+
情けないことにこのマナー違反に気付けませんでした。。
|
8
|
-
|
9
|
-
事前準備:以下C#コード実行パスと同階層に"test.py"(実行したいPythonコード)を配置
|
10
|
-
//--Pythonコードの実行--//
|
11
|
-
using Python.RunTime;
|
12
|
-
|
13
|
-
//初期化
|
14
|
-
public PyObject myMath = null;
|
15
|
-
|
16
|
-
//Grobal Interpreter Lockを取得
|
17
|
-
Py.GIL();
|
18
|
-
|
19
|
-
//コードのインポート
|
20
|
-
myMath = Py.Import("test");←ここで例外エラー発生
|
21
|
-
|
22
|
-
|
4
|
+
こちらの記事を削除します。
|
23
|
-
Python.Runtime.PythonException: AttributeError: 'NoneType' object has no attribute 'write'
|
24
|
-
|
25
|
-
<エラー詳細(抜粋)>
|
26
|
-
*****例外テキスト*****
|
27
|
-
Python.Runtime.PythonException: AttributeError: 'NoneType' object has no attribute 'write'
|
28
|
-
場所 Python.Runtime.Runtime.CheckExpectionOccurred()
|
29
|
-
場所 Python.Runtime.PythonEngine.ImportModule(String name)
|
30
|
-
|
31
|
-
|
32
|
-
<補足>
|
33
|
-
デバッグで実行した場合→エラー発生せず、Import成功(ただしImport時に数秒時間がかかる)
|
34
|
-
デバッグ(マネージド互換モード)で実行した場合→エラー発生
|
35
|
-
.exeから実行→.exe起動と同時にエラー発生し、変数myMathにnullが格納される
|