我有一个用Python 3.8编写的脚本和一个用Python 2.7编写的函数。 该函数不能在Python3.8中传输,因为它使用专门为Python2.7设计的API。我已经搜索了几种解决方案,例如使用execnet和子流程,如本thread中所述
仔细实施上述线程中描述的最佳解决方案,即:
import execnet
def call_python_version(Version, Module, Function, ArgumentList):
gw = execnet.makegateway("popen//python=python%s" % Version)
channel = gw.remote_exec("""
from %s import %s as the_function
channel.send(the_function(*channel.receive()))
""" % (Module, Function))
channel.send(ArgumentList)
return channel.receive()
脚本尝试执行下一行代码时出错:
gw = execnet.makegateway("popen//python=python%s" % Version)
我得到的错误是:
FileNotFoundError: [WinError 2] The system cannot find the file specified
你知道是什么导致了这个错误吗?也欢迎通过3.X脚本运行Python2.7
目前没有回答
相关问题 更多 >
编程相关推荐