I have file import1.py
:
import os
import runpy
filename = r'C:\pyinstallerTest\test.py'
runpy.run_path(filename)
File test.py
is:
import matplotlib.pyplot as plt
import numpy as np
from astroML import *
from tkinter import *
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig(r"C:\pyinstallerTest\test.png")
plt.show()
print('hello world')
I tried the following command for creating exe file from import1.py
pyinstaller --onefile import1.py
The import1.exe
file is created successfully. However, when I run the import1.exe
file, I get the following error:
Traceback (most recent call last):
File "import1.py", line 4, in <module>
File "runpy.py", line 263, in run_path
File "runpy.py", line 96, in _run_module_code
File "runpy.py", line 85, in _run_code
File "C:\pyinstallerTest\test.py", line 1, in <module>
import matplotlib.pyplot as plt
ImportError: No module named 'matplotlib'
[1828] Failed to execute script import1
This is more of learning exercise for me, so I am not looking for alternate better way of doing things here.