我在Ubuntu 18.04上使用以下命令为{strong> main.py 代码创建一个pyinstaller
可执行文件。
pyinstaller --onefile main.py
main.py :
#!/usr/bin/python3
def main():
print("Test")
if __name__ == "__main__":
main()
日志:
29 INFO: PyInstaller: 3.4
30 INFO: Python: 3.6.8
30 INFO: Platform: Linux-4.15.0-51-generic-x86_64-with-Ubuntu-18.04-bionic
30 INFO: wrote /home/ata/test-pyinstaller/main.spec
32 INFO: UPX is not available.
34 INFO: Extending PYTHONPATH with paths
['/home/ata/test-pyinstaller',
'/home/ata/test-pyinstaller']
34 INFO: checking Analysis
37 INFO: checking PYZ
39 INFO: checking PKG
39 INFO: Building because toc changed
39 INFO: Building PKG (CArchive) PKG-00.pkg
1871 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
1872 INFO: Bootloader /home/ata/.local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit/run
1872 INFO: checking EXE
1872 INFO: Building because name changed
1872 INFO: Building EXE from EXE-00.toc
Traceback (most recent call last):
File "/home/ata/.local/bin/pyinstaller", line 11, in <module>
sys.exit(run())
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 32, in <module>
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/building/api.py", line 433, in __init__
self.__postinit__()
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
self.assemble()
File "/home/ata/.local/lib/python3.6/site-packages/PyInstaller/building/api.py", line 509, in assemble
os.remove(self.name)
IsADirectoryError: [Errno 21] Is a directory: '/home/ata/test-pyinstaller/dist/main'
ata@sch:~/test-pyinstaller$ pyinstaller --onefile main.py
30 INFO: PyInstaller: 3.4
31 INFO: Python: 3.6.8
31 INFO: Platform: Linux-4.15.0-51-generic-x86_64-with-Ubuntu-18.04-bionic
32 INFO: wrote /home/ata/test-pyinstaller/main.spec
33 INFO: UPX is not available.
35 INFO: Extending PYTHONPATH with paths
['/home/ata/test-pyinstaller',
'/home/ata/test-pyinstaller']
35 INFO: checking Analysis
35 INFO: Building Analysis because Analysis-00.toc is non existent
36 INFO: Initializing module dependency graph...
38 INFO: Initializing module graph hooks...
39 INFO: Analyzing base_library.zip ...
2238 INFO: running Analysis Analysis-00.toc
2265 INFO: Caching module hooks...
2268 INFO: Analyzing /home/ata/test-pyinstaller/main.py
2272 INFO: Loading module hooks...
2273 INFO: Loading module hook "hook-xml.py"...
2448 INFO: Loading module hook "hook-encodings.py"...
2489 INFO: Loading module hook "hook-pydoc.py"...
2496 INFO: Looking for ctypes DLLs
2496 INFO: Analyzing run-time hooks ...
2503 INFO: Looking for dynamic libraries
2730 INFO: Looking for eggs
2730 INFO: Python library not in binary dependencies. Doing additional searching...
2793 INFO: Using Python library /usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0
2802 INFO: Warnings written to /home/ata/test-pyinstaller/build/main/warn-main.txt
2827 INFO: Graph cross-reference written to /home/ata/test-pyinstaller/build/main/xref-main.html
2831 INFO: checking PYZ
2831 INFO: Building PYZ because PYZ-00.toc is non existent
2831 INFO: Building PYZ (ZlibArchive) /home/ata/test-pyinstaller/build/main/PYZ-00.pyz
3061 INFO: Building PYZ (ZlibArchive) /home/ata/test-pyinstaller/build/main/PYZ-00.pyz completed successfully.
3062 INFO: checking PKG
3062 INFO: Building PKG because PKG-00.toc is non existent
3062 INFO: Building PKG (CArchive) PKG-00.pkg
4882 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
4883 INFO: Bootloader /home/ata/.local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit/run
4883 INFO: checking EXE
4883 INFO: Building EXE because EXE-00.toc is non existent
4883 INFO: Building EXE from EXE-00.toc
4883 INFO: Appending archive to ELF section in EXE /home/ata/test-pyinstaller/dist/main
4902 INFO: Building EXE from EXE-00.toc completed successfully.
在“ dist”子文件夹中创建了一个5.7 MB的文件,称为“ main”,但执行该文件后没有任何反应。
我在做什么错了?