我真的不知道还要做什么才能在.exe中编译我的项目。 尝试了很多教程,包括我在这里和github上找到的一个,但都没有成功
我使用pycharm社区版2021.1
我的指令:
Microsoft Windows [versão 10.0.19042.985]
(c) Microsoft Corporation. Todos os direitos reservados.
C:\WINDOWS\system32>python -m pip install pyinstaller
Requirement already satisfied: pyinstaller in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (4.3)
Requirement already satisfied: pefile>=2017.8.1 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.5.24)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.1)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: altgraph in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.17)
Requirement already satisfied: setuptools in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (56.0.0)
Requirement already satisfied: future in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
C:\WINDOWS\system32>
我的powershell:
PS C:\WINDOWS\system32> python -m pip install pyinstaller Requirement already satisfied: pyinstaller in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (4.3)
Requirement already satisfied: pefile>=2017.8.1 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.5.24)
Requirement already satisfied: pywin32-ctypes>=0.2.0 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (2021.1)
Requirement already satisfied: altgraph in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (0.17)
Requirement already satisfied: setuptools in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pyinstaller) (56.0.0)
Requirement already satisfied: future in c:\users\anton\appdata\local\programs\python\python39\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
PS C:\WINDOWS\system32>
我的pycharm终端:
(c) Microsoft Corporation. Todos os direitos reservados.
(venv) C:\Users\anton\PycharmProjects\Curso>\pyinstaller -w -F bobeiruda.py
'\pyinstaller' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
english: (pyinstaler is not recognized as an internal or external command, an operable program or a file in lots)
(venv) C:\Users\anton\PycharmProjects\Curso>python --version
Python 3.9.5
(venv) C:\Users\anton\PycharmProjects\Curso>pip --version
pip 21.1.2 from c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\pip (python 3.9)
(venv) C:\Users\anton\PycharmProjects\Curso>pyinstaller --version
4.3
(venv) C:\Users\anton\PycharmProjects\Curso>
pycharm pt2
(venv) C:\Users\anton\PycharmProjects\Curso>pyinstaller bobeiruda.py --onefile
100 INFO: PyInstaller: 4.3
100 INFO: Python: 3.9.5
116 INFO: Platform: Windows-10-10.0.19042-SP0
118 INFO: wrote C:\Users\anton\PycharmProjects\Curso\bobeiruda.spec
147 INFO: UPX is not available.
167 INFO: Extending PYTHONPATH with paths
['C:\\Users\\anton\\PycharmProjects\\Curso',
'C:\\Users\\anton\\PycharmProjects\\Curso']
pygame 2.0.1 (SDL 2.0.14, Python 3.9.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
3302 INFO: checking Analysis
3503 INFO: checking PYZ
3641 INFO: checking PKG
3641 INFO: Building PKG because PKG-00.toc is non existent
3641 INFO: Building PKG (CArchive) PKG-00.pkg
4297 WARNING: Can not get binary dependencies for file: C:\Users\anton\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python
.exe
4298 WARNING: Reason: 'The file is empty'
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\anton\PycharmProjects\Curso\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\build_main.py", line 737, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\build_main.py", line 684, in build
exec(code, spec_namespace)
File "C:\Users\anton\PycharmProjects\Curso\bobeiruda.spec", line 21, in <module>
exe = EXE(pyz,
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\api.py", line 438, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\api.py", line 200, in __init__
self.__postinit__()
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\building\api.py", line 279, in assemble
pylib_name = os.path.basename(bindepend.get_python_library_path())
File "c:\users\anton\pycharmprojects\curso\venv\lib\site-packages\PyInstaller\depend\bindepend.py", line 956, in get_python_library_path
raise IOError(msg)
OSError: Python library not found: libpython39.dll, libpython3.9m.dll, libpython39m.dll, libpython3.9.dll, python39.dll
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
(venv) C:\Users\anton\PycharmProjects\Curso>
我遵循了Missing dll files using PyInstaller on Windows教程,但没有任何更改,仍然无法编译我的文件: enter image description here
试试auto py to exe: 它是自我解释,只要你安装它通过命令。。。您可以通过命令访问它,并提示“auto py to exe”,然后您可以选择您的.py并将其转换为exe
试试
pyinstaller filename.py -w
或pyinstaller filename.py
。 删除onefile
在大多数情况下会产生问题。 并查看您是否正在从dist文件夹打开应用程序。如果使用生成文件夹打开,它将显示错误相关问题 更多 >
编程相关推荐