[Python] auto-py-to-exe is successfully installed, and an error is reported when starting ModuleNotFoundError: No module named 'PyInstaller'


foreword

The scripts we have written can run in our own local environment, and sometimes we need to put the scripts in other computer environments to run. However, in other environments, it is necessary to reinstall python and re-download the libraries required by the script, which is actually very inconvenient. It is very simple for students who are familiar with python, but it is more troublesome for those who have not been exposed to python, and we do not want to provide the source code of the script we wrote to others. We can use pyinstaller to package py scripts into exe executable files. There are many ways to use pyinstaller to package on the Internet, and we will introduce them here.
This article mainly introduces some problems and solutions during the installation process of auto-py-to-exe, for reference only.


1. Install auto-py-to-exe

We can enter pip install auto-py-to-exe on the command line to install.

pip install auto-py-to-exe

2. Problems encountered

Seeing the words "successfully installed", auto-py-to-exe has been successfully installed, but I have installed it to another path.
Successful installation
It can be seen that auto-py-to-exe is installed in another directory that is not in the path, and then enter auto-py-to-exe to start. The startup failed, prompting "ModuleNotFoundError: No module named 'PyInstaller'" could not find the pyinstaller module. Because auto-py-to-exe is packaged with py scripts based on pyinstaller. Since you can't find the pyinstaller module, install it, try it anyway. Then enter pip install pyinstaller in the cmd window to install pyinstaller, and "successfully installed" is also displayed, indicating that the pyinstaller module has been successfully installed. Re-enter auto-py-to-exe to start, and found that the error is still reported.
start error

3. Problem analysis

Because the installation location of auto-py-to-exe and yinstaller is not on the path during installation, it will prompt that the module cannot be found when starting . Uninstall these two modules and reinstall them. When the installation is successful, it will also prompt that the installation location is not on the path. Here, I hope that partners who know the reason can leave a message for guidance.

Four, the solution

Because conda is installed in the environment, I reinstalled pyinstaller and auto-py-to-exe in the virtual environment, and then started it, and it was ok.
auto-py-to-exe started successfully

Summarize

This article mainly introduces the problems encountered when installing and starting auto-py-to-exe. In a word, the installation location of anto-py-to-exe is not on the path, and an error will be reported when starting. At present, no solution has been found, but the installation is successful in the virtual environment and the startup is successful. But there are also benefits in the virtual environment, unnecessary modules can not be packaged. How should I put it, it can be said that it was a blessing in disguise. I personally feel that it is better to package in a virtual environment. The exe file generated after packaging is not so large, and the startup speed is not so slow. Finally, everyone is welcome to criticize and correct.

Guess you like

Origin blog.csdn.net/liaotianyin/article/details/130599204