首页 > 解决方案 > 使用 python 子进程调用时如何让 GAP 识别 Read("filename.g")

问题描述

我正在研究计算数论,我使用一个名为 GAP(组、代数和编程)的软件包。我想建立一个系统,我可以在其中调用 python 脚本来为我执行所有设置,以便我可以在一夜之间运行多个计算。

为此,我将需要定义的函数放入一些 .g 文件中。在 GAP 中调用这些函数的命令很简单:

Read("prelimcode1.g");

当我在间隙环境中尝试此操作时,它会为我执行设置。但是,当我尝试使用 python 读取这些文件时,我的 GAP 环境中出现了一个奇怪的错误。

我尝试的大多数修复都涉及重新组织我调用 Read("file"); 的方式。陈述。

def gapCaller():
    GAPpath = r'C:\gap-4.10.1\bin\gap.bat'
    deltasets= r'C:\Users\Dan\Desktop\deltasetfunctions\deltasetsinit.g'
    sp.Popen([GAPpath,deltasets])

我的预期结果是 GAP 会简单地读取文件。但是,我收到以下错误消息

>Syntax error: expression expected in 
C:\Users\Dan\Desktop\deltasetfunctions\deltasetsinit.g:1    
>Read("prelimcode1.g");  
>Read("prelimcode2.g");  
>Read("prelimcode3.g");  
>Read("prelimcode4.g");

带有指向第一个 R 的指示符。

标签: pythonsubprocessgap-system

解决方案


推荐阅读