.net Iron Python-没有名为“Iron Python”的模块;os";

.net Iron Python-没有名为“Iron Python”的模块;os";,.net,python,ironpython,.net,Python,Ironpython,我一直在尝试调试此示例代码,但遇到了问题 代码如下: import System import get_events_devices from System.Windows.Forms import * from System.ComponentModel import * from System.Drawing import * from clr import * clr.AddReference("IronPython") class Check: # namespace cl

我一直在尝试调试此示例代码,但遇到了问题

代码如下:

import System
import get_events_devices
from System.Windows.Forms import *
from System.ComponentModel import *
from System.Drawing import *
from clr import *
clr.AddReference("IronPython") 

class Check: # namespace

    class Form1(System.Windows.Forms.Form):
        """type(_label1) == System.Windows.Forms.Label, type(_button1) == System.Windows.Forms.Button"""
        __slots__ = ['_label1', '_button1']
        def __init__(self):

            self.InitializeComponent()

        @accepts(Self(), bool)
        @returns(None)
        def Dispose(self, disposing):

            super(type(self), self).Dispose(disposing)

        @returns(None)
        def InitializeComponent(self):
            self._button1 = System.Windows.Forms.Button()
            self._label1 = System.Windows.Forms.Label()
            self.SuspendLayout()
            # 
            # button1
            # 
            self._button1.Location = System.Drawing.Point(58, 61)
            self._button1.Name = 'button1'
            self._button1.Size = System.Drawing.Size(75, 23)
            self._button1.TabIndex = 0
            self._button1.Text = 'Click'
            self._button1.UseVisualStyleBackColor = True
            self._button1.Click += self._button1_Click
            # 
            # label1
            # 
            self._label1.AutoSize = True
            self._label1.Location = System.Drawing.Point(190, 70)
            self._label1.Name = 'label1'
            self._label1.Size = System.Drawing.Size(0, 13)
            self._label1.TabIndex = 1
            # 
            # Form1
            # 
            self.ClientSize = System.Drawing.Size(292, 273)
            self.Controls.Add(self._label1)
            self.Controls.Add(self._button1)
            self.Name = 'Form1'
            self.Text = 'Form1'
            self.ResumeLayout(False)
            self.PerformLayout()

        @accepts(Self(), System.Object, System.EventArgs)
        @returns(None)
        def _button1_Click(self, sender, e):

            # Snippet Statement
            pass
            # End Snippet Statement
            self._label1.Text = 'mohsin'
            get_events_devices.units()
我刚刚添加了optparse.py、get_events_devices.py和iron python.dll

我从哪里得到ironpython_module.dll,因为我已经安装了ironpython,我没有得到这个.dll


有什么想法吗?

如果您正在使用Visual Studio通过IronPython工具运行和调试Python代码,可能是您的
sys.path
没有包含对所有IronPython模块(如
os
)的引用

在代码中,尝试添加以下内容以指示IronPython的安装目录:

import sys
sys.path.append(r"C:\Program Files\IronPython 2.7\Lib")

上面是一个解决办法。

在python脚本中,您需要显式导入os.py的lib path

import sys
sys.path.append("C:\\Program Files (x86)\\IronPython 2.7\\Lib\\")
尝试添加代码:

import sys

sys.path.append("c:\python27\lib")

此代码对我有效,并解决了错误

问题是什么?你在“问题”中的评论似乎与主题也没有任何关系。我已经告诉过你我添加了哪些DLL,代码就在那里,但在那之后,我在get_events_devices.py中作为主题出现了错误??明白了,给我们实际的错误回溯。很明显我们不明白你在问什么。告诉我你的“问题”中有什么没有帮助。请写一个简短的段落解释你问题中的这句话“我从哪里获得ironpython_module.dll,因为我已经安装了Iron Python,我没有得到这个.dll?”并发布错误消息。这里是堆栈溢出。这个答案与投票率最高的答案重复。更糟糕的是,它提供的信息更少。请在自己回复之前仔细阅读已经提供的回复。