我想用pyinstaller创建一个简单python脚本的简单.exe文件。我遵循指南(https://www.pyinstaller.org/):
但我没有获得DIST文件夹中的.exe文件,如https://pyinstaller.readthedocs.io/en/stable/usage.html中所述:
In the dist folder you find the bundled app you distribute to your users.
我将Python3.7.6与anaconda一起使用。我首先从www.pypi.org/project/pyinstaller/下载PyInstaller,它是版本4.2,但它给了我相同的以下错误,所以我尝试使用正在开发的最新版本5.0
在我的情况下,我在Anaconda提示符下执行:
C:\Users\David Gomez\Desktop\test>pyinstaller simple.py
我获得:
1418 INFO: PyInstaller: 5.0.dev0
1418 INFO: Python: 3.7.6 (conda)
1418 INFO: Platform: Windows-10-10.0.19041-SP0
1432 INFO: wrote C:\Users\David Gomez\Desktop\test\simple.spec
1434 INFO: UPX is not available.
script 'C:\Users\David Gomez\Desktop\test\simple.py' not found
然后找不到脚本。经过一些研究,我认为问题在于我的名字“David Gomez”之间的路径空间,所以我用引号写下了路径:
C:\Users\David Gomez\Desktop\test>pyinstaller "C:\Users\David Gomez\Desktop\test\simple.py"
但同样的错误依然存在
然后我发现另一个人也有同样的问题(Script not found when using pyinstaller),但答案并不令人信服,我显然不想安装另一个python。我创建了一个新主题,因为该主题不再更新,建议的解决方案:
I found the solution. I had to first install Python from their own website instead of the Windows store. Then I had to add it to a PATH. After this it still did not work because I used Python 3.8.0, so I had to install pyinstaller development version.
你知道问题出在哪里吗?任何帮助或猜测都将不胜感激。如果需要进一步澄清,请告诉我
编辑的部分
当我用命令dir
检查我的文件夹时,我获得:
C:\Users\David Gomez\Desktop\test>dir
Le volume dans le lecteur C s’appelle Windows
Le numéro de série du volume est 3AFA-C44C
Répertoire de C:\Users\David Gomez\Desktop\test
15.03.2021 11:20 <DIR> .
15.03.2021 11:20 <DIR> ..
11.03.2021 15:52 160 simple.py.py
1 fichier(s) 160 octets
2 Rép(s) 166,905,487,360 octets libres
然后,我执行命令C:\Users\David Gomez\Desktop\test>pyinstaller "C:\Users\David Gomez\Desktop\test\simple.py"
,创建了两个新的空文件夹(build,dist)和一个文件simple.spec。通常情况下,如果一切正常工作,文件夹不是空的。现在,如果我用dir
命令再次检查我的文件夹:
C:\Users\David Gomez\Desktop\test>dir
Le volume dans le lecteur C s’appelle Windows
Le numéro de série du volume est 3AFA-C44C
Répertoire de C:\Users\David Gomez\Desktop\test
11.03.2021 16:57 <DIR> .
11.03.2021 16:57 <DIR> ..
11.03.2021 16:57 <DIR> build
11.03.2021 16:57 <DIR> dist
11.03.2021 15:52 160 simple.py.py
11.03.2021 17:41 1,059 simple.spec
2 fichier(s) 1,219 octets
4 Rép(s) 166,908,215,296 octets libres
Simply.py在文件夹中,但pyinstaller没有找到,我仍然不知道该怎么做
我不知道它是否有用,但这里有simple.spec的内容:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['simple.py'],
pathex=['C:\\Users\\David Gomez\\Desktop\\test'],
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='simple',
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,
upx_exclude=[],
name='simple')
您的问题与pyinstaller安装位置无关,而是该目录中不存在
simple.py
文件。(至少在我看来是这样的)相关问题 更多 >
编程相关推荐