我正在做一个基本的.py代码input("Worked")
,并试图将其转换为.exe。
当我将此代码作为.py文件运行时,它将在屏幕上打印Worked
,并等待我按Enter。
我打开了C:\Users\enzo
命令
然后我在使用(ENV) C:\Users\enzo
的virtualenv上输入
然后我进入项目目录C:\Users\enzo\desktop\Compilando
该目录除了abc.py
文件之外没有其他内容。
然后我使用了命令:pyinstaller abc.py
该目录现在有abc.py, abc.spec, build, dist, __pycache__
当我打开build\abc\abc.exe
时,控制台会出现,但同时会关闭。
当我打开dist\abc\abc.exe
时,发生了同样的事情。
我在没有virtualenv的情况下尝试过,但是我得到了相同的结果。
我尝试以管理员身份运行cmd和.exe文件,但是发生了相同的情况
如何使.exe文件作为.py文件运行?
# -*- mode: python -*-
block_cipher = None
a = Analysis(['abc.py'],
pathex=['C:\\Users\\enzo\\Desktop\\Compilando'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='abc',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='abc')
This file lists modules PyInstaller was not able to find. This does not
necessarily mean this module is required for running you program. Python and
Python 3rd-party packages include a lot of conditional or optional module. For
example the module 'ntpath' only exists on Windows, whereas the module
'posixpath' only exists on Posix systems.
Types if import:
* top-level: imported at the top-level - look at these first
* conditional: imported within an if-statement
* delayed: imported from within a function
* optional: imported within a try-except-statement
IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
yourself tracking down the missing module. Thanks!
missing module named resource - imported by posix (top-level), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named posix - imported by os (conditional, optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named _posixsubprocess - imported by subprocess (conditional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named 'org.python' - imported by pickle (optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level), xml.sax (delayed, conditional)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named _winreg - imported by platform (delayed, optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named java - imported by platform (delayed), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named 'java.lang' - imported by platform (delayed, optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level), xml.sax._exceptions (conditional)
missing module named vms_lib - imported by platform (delayed, conditional, optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named termios - imported by tty (top-level), C:\Users\enzo\Desktop\Compilando\abc.py (top-level), getpass (optional)
missing module named grp - imported by shutil (optional), tarfile (optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), C:\Users\enzo\Desktop\Compilando\abc.py (top-level), netrc (delayed, conditional), getpass (delayed)
missing module named org - imported by copy (optional), C:\Users\enzo\Desktop\Compilando\abc.py (top-level)
79 INFO: PyInstaller: 3.4
79 INFO: Python: 3.7.2rc1
79 INFO: Platform: Windows-10-10.0.17134-SP0
79 INFO: wrote C:\Users\enzo\Desktop\Compilando\abc.spec
79 INFO: UPX is not available.
79 INFO: Extending PYTHONPATH with paths
['C:\\Users\\enzo\\Desktop\\Compilando', 'C:\\Users\\enzo\\Desktop\\Compilando']
79 INFO: checking Analysis
79 INFO: Building Analysis because Analysis-00.toc is non existent
79 INFO: Initializing module dependency graph...
95 INFO: Initializing module graph hooks...
95 INFO: Analyzing base_library.zip ...
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "c:\users\enzo\desktop\env\lib\io.py", line 52, in <module>
File "C:\Users\enzo\Desktop\Compilando\abc.py", line 1, in <module>
RuntimeError: input(): lost sys.stdin
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "c:\users\enzo\desktop\env\lib\io.py", line 52, in <module>
File "C:\Users\enzo\Desktop\Compilando\abc.py", line 1, in <module>
RuntimeError: input(): lost sys.stdin
2616 INFO: running Analysis Analysis-00.toc
2616 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\enzo\desktop\env\scripts\python.exe
2647 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python.exe
2663 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python.exe
2679 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python.exe
2710 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python.exe
2725 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python.exe
2757 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\WINDOWS\system32\vcruntime140.dll
2789 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\WINDOWS\system32\vcruntime140.dll
2809 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\WINDOWS\system32\vcruntime140.dll
2817 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\WINDOWS\system32\vcruntime140.dll
2848 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\WINDOWS\system32\vcruntime140.dll
2973 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3006 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3027 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3042 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3058 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3089 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3105 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3136 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3152 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3167 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3198 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3214 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\enzo\desktop\env\scripts\python37.dll
3214 INFO: Caching module hooks...
3214 INFO: Analyzing C:\Users\enzo\Desktop\Compilando\abc.py
3214 INFO: Loading module hooks...
3230 INFO: Loading module hook "hook-encodings.py"...
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "c:\users\enzo\desktop\env\lib\io.py", line 52, in <module>
File "C:\Users\enzo\Desktop\Compilando\abc.py", line 1, in <module>
RuntimeError: input(): lost sys.stdin
3386 INFO: Loading module hook "hook-pydoc.py"...
3386 INFO: Loading module hook "hook-xml.py"...
3590 INFO: Looking for ctypes DLLs
3590 INFO: Analyzing run-time hooks ...
3590 INFO: Looking for dynamic libraries
3621 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_ssl.pyd
3652 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_ssl.pyd
3668 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_ssl.pyd
3699 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\pyexpat.pyd
3715 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\pyexpat.pyd
3746 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\pyexpat.pyd
3761 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\pyexpat.pyd
3777 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\pyexpat.pyd
3808 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_hashlib.pyd
3840 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_bz2.pyd
3871 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_bz2.pyd
3886 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_bz2.pyd
3902 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_bz2.pyd
3933 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_bz2.pyd
3949 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_lzma.pyd
3980 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_lzma.pyd
3996 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_socket.pyd
4027 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\_socket.pyd
4058 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\select.pyd
4090 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libssl-1_1-x64.dll
4105 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libssl-1_1-x64.dll
4136 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libssl-1_1-x64.dll
4168 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libssl-1_1-x64.dll
4824 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4839 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4871 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4886 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4918 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4933 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4964 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
4980 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
5012 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\Users\enzo\AppData\Local\Programs\Python\Python37\DLLs\libcrypto-1_1-x64.dll
5012 INFO: Looking for eggs
5014 INFO: Using Python library c:\users\enzo\desktop\env\scripts\python37.dll
5014 INFO: Found binding redirects:
[]
5015 INFO: Warnings written to C:\Users\enzo\Desktop\Compilando\build\abc\warn-abc.txt
5031 INFO: Graph cross-reference written to C:\Users\enzo\Desktop\Compilando\build\abc\xref-abc.html
5062 INFO: checking PYZ
5062 INFO: Building PYZ because PYZ-00.toc is non existent
5062 INFO: Building PYZ (ZlibArchive) C:\Users\enzo\Desktop\Compilando\build\abc\PYZ-00.pyz
5500 INFO: Building PYZ (ZlibArchive) C:\Users\enzo\Desktop\Compilando\build\abc\PYZ-00.pyz completed successfully.
5515 INFO: checking PKG
5515 INFO: Building PKG because PKG-00.toc is non existent
5515 INFO: Building PKG (CArchive) PKG-00.pkg
5531 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
5531 INFO: Bootloader c:\users\enzo\desktop\env\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
5531 INFO: checking EXE
5531 INFO: Building EXE because EXE-00.toc is non existent
5531 INFO: Building EXE from EXE-00.toc
5531 INFO: Appending archive to EXE C:\Users\enzo\Desktop\Compilando\build\abc\abc.exe
5593 INFO: Building EXE from EXE-00.toc completed successfully.
5593 INFO: checking COLLECT
5593 INFO: Building COLLECT because COLLECT-00.toc is non existent
5593 INFO: Building COLLECT COLLECT-00.toc
5820 INFO: Building COLLECT COLLECT-00.toc completed successfully.
很抱歉这个大问题。