Due to various circumstances, there was a case where the graph drawing function of Python was used on Windows, which is a non-Python execution environment, so it is described as a memorandum. It might be nuget, but I couldn't find out ...
OS: Windows 10 64bit Python:3.6.10 Pyinstaller:3.5
Since I want a heatmap graph this time, I created a script "heatMap.py" that draws a heatmap and saves it as .png. Eventually, .exe will be executed from Windows, so for ease of use,
import sys
import os
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
def Heatmap(data):
ax = sns.heatmap(data,annot=True)
return ax
if __name__ == '__main__':
args = sys.argv
load_path = args[1]
save_path = args[2]
save_name = args[3]
print(load_path,save_path,save_name)
data = np.loadtxt(load_path,delimiter=",")
hoge = Heatmap(data)
hoge.plot()
plt.savefig(os.path.join(save_path,save_name),facecolor="blue")
First argument args [1]: Data source (csv file) path + file specification Second argument args [2]: Specify the path to save the graph Third argument args [3]: Graph name. Save format specified
See here for python argument execution, For the savefig path specification of matplotlib, refer to here.
Create .exe with pyinstaller by referring to this article.
A folder including related dlls has been created.
[App.exe] [First argument] [Second argument] [Third argument]
C:\Users\user.name>heatMap.exe C:\Users\user.name\Documents\Python\Graph\DataSrc\matrix.csv C:\Users\user.name\Documents\Python\Graph\GraphDst heatMapTest.png
It's done.
However, it takes a few seconds to execute this because it is a policy to execute it from the beginning every time. → Actual measurement about 4 seconds Since File saving is repeated, it is not suitable for the purpose of executing this .exe on the Windows application side and importing the output file to the application side. (I can do it if it's late) Next time, make .exe always up and return it by interprocess communication
Recommended Posts