问题
I was able to get exe file from py using pyinstaller. I used the following code:
pyinstaller -y -F --additional-hooks-dir=. --add-binary ibm_db_dlls;.\ibm_db_dlls Data_QC_Ver1.py
this work fine on my laptop, however when trying it on a different machine I get the following error:
回答1:
Before I go further into my suggestion an answer in a stack overflow question (see below) that I found was to make sure you have installed pyinstaller and Pywin32
This answer refers to an alternative to Pyinstaller as discussed in comments. You could use auto-py-to-exe. First you must have PIP set-up on your device. This page can help you set PIP up, This video can add extra support. After that open your cmd as administrator and type in pip install auto-py-to-exe
. If you get no errors you are ready to move on.
Then type auto-py-to-exe
in cmd and you should get this GUI:
Do ignore the script location and icon fields as they are already filled in here. Browse/Search for your .Py and then choose your certain fields. Here are some tips:
You must only select window based when you have a GUI built into your program - otherwise your text such as print()
will not show.
It is more secure to select one file over one directory (one folder) as in one directory other users can see the content of your executable file.
After this you can add other files (like .txt) and an icon. Click on convert and select output folder when prompted. If, when you try and run your application, the file crashes or just closes without warning you either have an error in your code or what you have selected in your building application is wrong and you will need to try again.
I know that this answer relates to another application than Pyinstaller but I personally find this much easier. Alternativley you can check This stack overflow question as I belive it is asking the same question as you have asked. Another fabulous tool for this (there are so many) is cx_Freeze. I hope this can be of some use to you.
来源:https://stackoverflow.com/questions/61014358/importerror-dll-load-failed-the-specified-module-could-not-be-found-on-a-dif