visual studio写python,在visual studio中执行python文件时出错

I'm adding python script in my website which i'm using it for serial communication and to do so i'm using ironpython...

Following is the Codebehind file of my webpage:--

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using IronPython.Hosting;

using Microsoft.Scripting.Hosting;

using Microsoft.Scripting;

using IronPython.Runtime;

public partial class _Default : System.Web.UI.Page

{

static ScriptEngine engine = Python.CreateEngine();

ScriptScope pyScope = engine.CreateScope();

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

try

{

ScriptEngine pyEngine = Python.CreateEngine();

pyEngine.ExecuteFile(@"D:\project\App_8th Sem\FinalDesign v0.3\scan.py");//error here

}

catch (Exception eo)

{

Label1.Text = "err ==" + eo;

}

}

}

Scan.py file:==

import serial

print 'hello... '

so when i click on button it gives me python runtime exception as below :--

"

IronPython.Runtime.Exceptions.ImportException: No module named serial at Microsoft.Scripting.Runtime.LightExceptions.CheckAndThrow(Object value) at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at IronPython.Compiler.PythonScriptCode.Run(Scope scope) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path) at _Default.Button1_Click(Object sender, EventArgs e) in d:\project\App_8th Sem\FinalDesign v0.3\admDefault.aspx.cs:line 37

"

and i also installed pyserial on my pc..

so am i missing some kind of reference dll or what??

解决方案

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值