2016-01-20 129 views
4

我在Windows上有Windows 7 x64和Python 2.7.6版本。 安裝的框架爲:Pythonnet錯誤:動態模塊未正確初始化

Microsoft .NET Framework 4.5.2 Microsoft .NET Framework 4多目標定位包。 所以,當我跑我的應用程序,他crashs上:

import clr 

與此錯誤:

SystemError: dynamic module not initialized properly 

我也重建pythonnet使用Visual C#2010 Express中,與x86平臺,但沒有什麼。

任何人都可以幫助我。 可能任何人都可以告訴我使用pythonnet安裝的必需的.NET Framework。

+1

你按照安裝說明進行這裏:http://stackoverflow.com/a/25091750/2230844? – denfromufa

+0

坦克你非常多。我解決了這個帖子,你建議:) –

回答

2

我也有這種行爲。我通過通過PIP安裝Python.net固定它:

python -m pip install pythonnet(可能需要以管理員/根用戶身份運行)執行

> python 
> import clr 
1

的錯誤,當安裝完成後你不應該得到任何錯誤後

因爲你的clr.pyd找不到Python.Runtime.dll。基本上你已經成功地導入了clr.pyd,但你的clr.pyd找不到Python.runtime.dll。因此,爲了讓您的dll可搜索,您需要將您的Python.Runtime.dll的位置添加到System PATH

比方說,你有你的main.pyimport clr和你clr.pyd並在同一目錄Python.Runtime.dll,你只需要添加下面幾行你main.py的開頭:

import sys 
import os 

sys.path.insert(0, os.path.abspath('./')) # add the current file location to sys path so that the clr module is searchable