当前位置: 首页 > 编程语言 > C#

IronPython-Unexpectedtoken'from'分享

时间:2023-04-10 19:24:42 C#

IronPython:Unexpectedtoken'from'是使用System的C#代码;使用系统文本;使用System.IO;使用IronPython.Hosting;使用System.Collections.Generic;使用Microsoft.Scripting.Hosting;namespaceConsoleApplication1{classProgram{privatestaticvoidMain(){varpy=Python.CreateEngine();列出searchPaths=newList();searchPaths.Add(@"C:UsersAdminAppDataLocalProgramsPythonPython35Lib)");searchPaths.Add(@"C:UsersAdminAppDataLocalProgramsPythonPython35Libsite-packages)");py。设置搜索路径(搜索路径);尝试{py.ExecuteFile("script.py");}catch(Exceptionex){Console.WriteLine(ex.Message);}}}}以下是我的输出意外标记“来自”如果我删除导入语句,则python脚本执行正常。我尝试包括os,sys所有这些导入,没有任何问题。我通过pip安装了TensorFlow,当我通过python控制台(v3.5)运行上述脚本时,它工作正常。更新:在TF文档中,写到“TensorFlow仅支持Windows上的Python3.5.x版本”。但是IronPython的正式版本是2.7版我很高兴地在GitHub上找到了IronPython,并尝试构建它(我只是在控制台中输入build并被它显示的一长串错误消息吓坏了!:DCouldnotfindprecompiledbinarywithIs在IronPython2.7中导入tensorflow或在.net中运行Python有什么替代方法吗?Prakash-正如您在文档中发现的那样,TensorFlow需要Python3.5或3.6才能在Windows上运行。它不会在IronPython2.7中运行。GitHub上的用户有一种在TF2.7上运行TF2的成功(大量工作且不容易做到)方式,您可以在他们的工作的基础上进行构建,但这不是您寻找IronPython的解决方案。我最好的建议是使用3.5或3.6.以上就是C#学习教程:IronPython:Unexpectedtoken'from'分享全文,如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注-本文整理自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: