问题描述
我正在Windows上工作,通过conda使用pyinstaller。我有使用oct2py和这样的代码test_writing.py的python文件:
# set Octave kernel
# (needed to run exe from any computer,even without Octave)
os.environ["OCTAVE_EXECUTABLE"] = resource_path('Octave-5.1.0.0\\mingw64\\bin\\octave-cli.exe')
os.environ["OCTAVE_KERNEL_JSON"] = resource_path('Octave-5.1.0.0\\kernel.json')
import oct2py
oct = oct2py.Oct2Py(temp_dir=resource_path("."))
res = oct.test_writing(os.path.abspath("."))
np.savetxt('saved_from_python.csv',res,delimiter=',')
使用了Bundling data files with PyInstaller (--onefile)中的函子resource_path
。这是倍频程函数:
function res = test_writing (path)
disp('WELCOME TO OCTAVE')
res = [1 2 3; 5 5 5];
disp(path)
dlmwrite(strcat(path,'\saved_from_octave.csv'),',')
endfunction
我正在通过pyinstaller --onefile test_writing.spec
和带有datas = [('Octave-5.1.0.0','Octave-5.1.0.0'),('reader.mat','.')]
的经过修改的.spec文件来构建exe。
当我通过PyCharm运行test_writing.py
时,它将显示所有Octave和python输出,并创建saved_from_octave.csv
和saved_from_python.csv
文件。但是,如果我制作一个.exe并运行,它只会跳过八度打印和保存,并且仅使用python输出和文件saved_from_python.csv
来完成程序。这样,我就没有保存过Octave文件(以及输出)了。
根据我发送到八度的保存路径,save_from_octave.csv应该出现在带有.exe的目录中 我确实需要有机会将数据保存在八度代码中,而无需将数据从八度传输到Python。 你能帮忙吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)