When I run my program that I compiled from python to exe with pyinstaller it gives an error (I use python 2.7.16):
Traceback (most recent call last):
File "bloepie.py", line 1, in <module>
File "c:\users\stefan\appdata\local\temp\pip-install-v9ecuy\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "build\bdist.win-amd64\egg\bluetooth\__init__.py", line 37, in <module>
File "c:\users\stefan\appdata\local\temp\pip-install-v9ecuy\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "build\bdist.win-amd64\egg\bluetooth\msbt.py", line 2, in <module>
File "c:\users\stefan\appdata\local\temp\pip-install-v9ecuy\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 395, in load_module
File "build\bdist.win-amd64\egg\bluetooth\_msbt.py", line 7, in <module>
File "build\bdist.win-amd64\egg\bluetooth\_msbt.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
[21200] Failed to execute script bloepie
I compiled it with:
pyinstaller bloepie.py --onefile
this person had the same problem as me but the only answer he got was that he should upgrade to python 3 or higher which I don't want to do and it wasn't marked as correct answer so I also have no guarantee that if I did it it would work. This person has a slightly different issue though. I have a "Import error: DLL failed to load: ..." he has a normal Import error (I don't know if this makes a difference but I couldn't find anything about it)
Here is the python code I compiled with pyinstaller:
import bluetooth
from pynput.mouse import Button, Controller
mouse = Controller()
may_i = 0
may_x = 0
may_y = 0
lockdown = 0
server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
server_sock.bind(("",bluetooth.PORT_ANY))
server_sock.listen(1)
bluetooth.advertise_service(server_sock, "helloService",
service_classes=[bluetooth.SERIAL_PORT_CLASS],
profiles=[bluetooth.SERIAL_PORT_PROFILE])
client_sock, address = server_sock.accept()
print "Accepted connection from ",address
while True:
may_i = 0
gata = client_sock.recv(1024)
if gata == "":
break
data = gata.split(";")
for dt in data:
if dt == "":
may_i = 1
if dt == "Down":
loci = mouse.position
may_x = 0
may_y = 0
lockdown = 0
may_i = 1
if dt == "Up":
if may_x == 1 and may_y == 1 and lockdown == 0:
mouse.press(Button.left)
mouse.release(Button.left)
may_i = 1
if may_i == 0:
print "received: %s" % dt
if dt == "x0.0":
may_x = 1
if dt == "y0.0":
may_y = 1
if dt != "x0.0" and dt != "y0.0":
lockdown = 1
if "x" in dt:
dt = dt.replace("x", "")
if "-" in dt:
dt = dt.replace("-", "")
if dt.split(".")[0] != 0:
dt = str(float(dt) * 1.5)
mouse.position = (mouse.position[0] + int(dt.split(".")[0]), mouse.position[1])
else:
if dt.split(".")[0] != 0:
dt = str(float(dt) * 1.5)
mouse.position = (mouse.position[0] - int(dt.split(".")[0]), mouse.position[1])
if "y" in dt:
dt = dt.replace("y", "")
if "-" in dt:
dt = dt.replace("-", "")
if dt.split(".")[0] != 0:
dt = str(float(dt) * 1.5)
mouse.position = (mouse.position[0], mouse.position[1] + int(dt.split(".")[0]))
else:
if dt.split(".")[0] != 0:
dt = str(float(dt) * 1.5)
mouse.position = (mouse.position[0], mouse.position[1] - int(dt.split(".")[0]))
client_sock.close()
server_sock.close()
So what is going wrong here? Why isn't the compiled version running? (the py file works fine) Thanks
I have tried using hooks but it didn't work well for my code. Instead, I copy the whole scipy folder to the python code folder and the issue was fixed. In my computer, the scipy folder is in "D:\Programe\Anaconda\Lib\site-packages"
.
Wish it can help you.
In summary, my tips in package using pyinstaller shows below:
import sys sys.setrecursionlimit(5000)
Copy high-risk modules to the packaging folder to avoid DLL missing error. (In my work, Numpy, Scipy and Pandas are copied.)
For other error like module missing, you can fix the error by add the module in hiddenimports of the spec file.
Need update Pandas to 1.x.x version. Pandas 0.24.x version will show "No module named 'pandas._libs.tslib'" and cannot be fixed by hiddenimports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With