As the title, it fails every time I use Pyinstaller or py2exe to compile into .exe file.
I've tried this simple code taken from as the example (in NetworkX cannot save a graph as jpg or png file)
import networkx as nx
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12,12))
ax = plt.subplot(111)
ax.set_title('Graph - Shapes', fontsize=10)
G = nx.DiGraph()
G.add_node('shape1', level=1)
G.add_node('shape2', level=2)
G.add_node('shape3', level=2)
G.add_node('shape4', level=3)
G.add_edge('shape1', 'shape2')
G.add_edge('shape1', 'shape3')
G.add_edge('shape3', 'shape4')
pos = nx.spring_layout(G)
nx.draw(G, pos, node_size=1500, node_color='yellow', font_size=8, font_weight='bold')
plt.tight_layout()
plt.savefig("Graph.png", format="PNG")
plt.show()
It worked fine on Jupyter Notebook and using cmd python graph.py
But it never run on complied .exe file.
- Pyinstaller's executable file crashes
- Py2exe's executable flashed error message when open the first time and it closed immediately so I don't know what was the error
My networkx version: 2.5, matplotlib: 3.2.2, python 3.8.3, newest pyinstaller and py2exe
Thank you in advance