如何解决pyinstaller不会使用oct2py
我正在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 举报,一经查实,本站将立刻删除。