In the venv environment, there is no exception in the packaging process when the command line pyinstaler is used to execute the packaging command. However, after the packaging is successful, it is executed. In the venv environment, the packaging process is normal when the command line pyinstaler is used to execute the packaging command. After the packaging is successful, the following similar errors appear when the dist/xxx.exe file is executed:
Traceback (most recent call last):
File "main.py", line 4, in <module>
import jcw
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "jcw.py", line 3, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Solution:
Because the running environment is venv virtual environment, the command line packaging may use the installation environment of Python in the computer, that is, the global environment and dependency library, which leads to the failure to include the required modules in the packaging.
Use another packaging method of pyinstaler official website, Python code to run the packaging command, such as:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import PyInstaller.__main__
import os
if __name__ == '__main__':
pyi_args = [
'--upx-dir=F:\\soft\\upx-3.96-win64',
'--clean',
'--add-data={0};.'.format(os.path.realpath('cfg.ini')),
'--add-binary={0};driver'.format(os.path.realpath('driver/chromedriver.exe')),
'--name=demo',
'main.py',
'-y'
]
print("pyinstaller " + " ".join(pyi_args))
PyInstaller.__main__.run(pyi_args=pyi_args)
Several ways of online search don’t work (you can try your own environment or not)
1.Move the import statement from the file header to the code block
2.Command line use — hidden import = missing module
Read More:
- [Mac M1] How to Solve import wordcloud Error: ModuleNotFoundError: No module named ‘wordcloud‘
- [Solved] ModuleNotFoundError: No module named ‘xxx’; ‘xxx’ is not a package
- [Solved] ModuleNotFoundError: No module named ‘requests‘
- ModuleNotFoundError: No module named ‘requests‘ [How to Solve]
- ModuleNotFoundError: No module named ‘tensorflow.python’ And the pits encountered after installation
- [Solved] ModuleNotFoundError: No module named ‘_polyiou‘
- [Solved] Pytest Error: E ModuleNotFoundError: No module named ‘common
- [Solved] ByteTrack Error: ModuleNotFoundError: No module named ‘yolox’
- [Solved] ModuleNotFoundError: No module named ‘pip‘
- ModuleNotFoundError: no module named ‘pip‘ [How to Solve]
- [Solved] Pychar error: modulenotfounderror: no module named ‘requests_ HTML ‘solution
- [Solved] modulenotfounderror: no module named ‘torchtext.legacy.data.datasets_ utils‘
- [Solved] scikit-learn Error: ModuleNotFoundError: No module named ‘sklearn.utils.linear_assignment_’
- [Solved] Jupyter notebook use pyLDAvis Error: modulenotfounderror: no module named ‘pyLDAvis’‘
- [Solved] jupyter notebook Error: ModuleNotFoundError: No module named jupyter_nbextensions_configurator
- The solution of no such file or directory and cannot load native module running error of python3 pyinstaller after packaging
- Module not found error: no module named ‘filefolder’ appears when learning engineering knowledge
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’
- Module notfounderror when installing suds: no module named ‘client’ solution
- Django uses Mysql to report an error loading MySQL DB module: no module named ‘mysqldb’