When trying to make a executable with PyInstaller i get this error;
AttributeError: module 'test' has no attribute 'sayhello'
This is the script i used to make the executable;
import test
test.sayhello()
In the same directory i have test.py with includes nothing more then;
def sayhello():
print('Hello')
This is my.spec file that was made by PyInstaller;
Can anybody help me with this error? I also tried PyInstallers '--hidden-import' option but that didn't seem to work either.
Thanks alot!
Try to create virtual environment (venv environment) and install all your packages in venv file by activating virtual environment. And also install pyinstaller in it and run your command from activated virtual environment as like
python -m pyinstaller python.py # your py file
If this wan't help then try this as administrator some time it needs administrator permission in windows if you are not on windows then use sudo for terminal.
May this help you.
I got a way around it that works for me. And maybe it might work for you to. I just made two executables with PyInstaller for both scripts.
One script says;
from subprocess import Popen
filename = 'File2OPC.exe'
while True:
print("\nStarting " + filename)
p = Popen(filename, shell=True)
p.wait()
And the other script can be anything. The script above just starts the executable. For my usages this is fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.