.NET 4.0에 파이썬 2.6을 포함하려고합니다. 다음과 같이 ".NET을위한 파이썬"의 아주 최소한의 문서에 따라Python for .NET : ImportError : 경고라는 모듈이 없습니다.
는, 나는 매우 간단한 코드를 작성 :
test.py 내가 없음 모듈 이름이 없습니다 "라는 가져 오기 오류가 비어있는 경우에도const string pythonModulePath = @"C:\Projects\PythonImport\PythonImport\test.py";
Environment.SetEnvironmentVariable("PYTHONHOME", Path.GetDirectoryName(python
ModulePath));
PythonEngine.Initialize();
var oldWorkingDirectory = Directory.GetCurrentDirectory();
var currWorkingDirectory = Path.GetDirectoryName(pythonModulePath);
Directory.SetCurrentDirectory(currWorkingDirectory);
var pyPlugin = PythonEngine.ImportModule(Path.GetFileNameWithoutExtension(python
ModulePath));
if (pyPlugin == null)
{
throw new PythonException();
}
Directory.SetCurrentDirectory(oldWorkingDirectory);
경고 ".
'import site' failed; use -v for traceback
Unhandled Exception: Python.Runtime.PythonException: ImportError : No module nam
ed warnings
"python -v"(자세한 정보 표시 모드)를 사용하여 test.py를 실행하면 그 이유가 분명해집니다. python은 #cleanup [2] 경고를 호출합니다.
왜 파이썬 .NET은 경고를 해결할 수 없습니까? 모듈이 Lib 디렉토리에 있습니다.
아이디어가 있으십니까?