如何在QtCreator中单击按钮运行python程序并在Qlabel上显示结果
我试图在点击按钮时运行执行python程序,但出现错误 Qt程序:如何在QtCreator中单击按钮运行python程序并在Qlabel上显示结果,python,pandas,qt,libraries,Python,Pandas,Qt,Libraries,我试图在点击按钮时运行执行python程序,但出现错误 Qt程序: QProcess p; QStringList params; params<<"C:/Users/user/Desktop/image/temp.py"; p.start("C:/Users/user/anaconda3/python.exe",params); p.waitForFinished(-1); qDebug()<<"fin
QProcess p;
QStringList params;
params<<"C:/Users/user/Desktop/image/temp.py";
p.start("C:/Users/user/anaconda3/python.exe",params);
p.waitForFinished(-1);
qDebug()<<"finished";
QStringp_stdout=p.readAll();
qDebug()<<p_stdout;
QStringp_stderr=p.readAllStandardError();
if(!p_stderr.isEmpty());
qDebug()<<"Pythonerror:"<<p_stderr;
from PIL import Image
import numpy as np
def change(path1,path2):
im1=Image.open(path1,"r")
im2=Image.open(path2,"r")
buffer1=np.asarray(im1)
buffer2=np.asarray(im2)
buffer3=buffer1-buffer2
changed=Image.fromarray(buffer3)
im1.show()
im2.show()
changed.show()
changed.save(r"C:\Users\user\Desktop\image\changed.jpg")
return(changed.show)
change(r"C:\Users\user\Desktop\image\Vale.jpg",r"C:\Users\user\Desktop\image\Vale2.jpg")
QT上出现错误:
finished
""
Python error:
"Traceback (most recent call last):\r\n File "C:/Users/user/Desktop/image/temp.py", line 1, in <module>\r\n from PIL import Image\r\n File "C:\Users\user\anaconda3\lib\site-packages\PIL\Image.py", line 94, in <module>\r\n from . import _imaging as core\r\nImportError: DLL load failed while importing _imaging: The specified module could not be found.\r\n"
File "C:/Users/user/Desktop/image/temp.py", line 1, in <module>
from PIL import Image
File "C:\Users\user\anaconda3\lib\site-packages\PIL\Image.py", line 94, in <module>
from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.
完成
""
Python错误:
“回溯(最近一次调用):\r\n文件“C:/Users/user/Desktop/image/temp.py”,第1行,从PIL导入映像\r\n文件“C:\Users\user\anaconda3\lib\site packages\PIL\image.py”,第94行,从.import\r\n作为核心导入映像\r\nImporter错误:导入映像时DLL加载失败:找不到指定的模块。\r\n”
Qt中的第二种方法:(python程序与temp.py相同)
QStringprogram(“C:/Users/user/anaconda3/python.exe”);
QStringListargs=QStringList()导入时链接器错误似乎是导入错误:DLL加载失败\u映像:找不到指定的模块。
在这两种情况下返回的都是问题所在。如果有其他方法,请告诉。尝试此操作:添加DLL位置(例如:C:\Programs\Python\Python35\DLS on windows)在环境变量path.u中,您的意思是添加python的路径吗?实际上我正在使用spyder(AnacondaIDE)。我应该添加anaconda的python的位置吗?
File "C:/Users/user/Desktop/image/temp.py", line 1, in <module>
from PIL import Image
File "C:\Users\user\anaconda3\lib\site-packages\PIL\Image.py", line 94, in <module>
from . import _imaging as core
ImportError: DLL load failed while importing _imaging: The specified module could not be found.