Ash*_*dke 5 python pip pyinstaller python-3.x
我正在尝试使用 pyinstaller 使用以下命令创建可执行文件:
pyinstaller <script>.py
Run Code Online (Sandbox Code Playgroud)
它在 Linux 中运行得非常好,但不知何故这似乎不适用于 Windows。
Python : 3.5
Pyinstaller : 3.4
Run Code Online (Sandbox Code Playgroud)
但它不断抛出错误,因为系统找不到指定的路径:C:\folder\build\scriptname
而构建文件夹通常是在执行 PyInstaller 命令后创建的。
Traceback (most recent call last):
File "C:\Program Files\Python 3.5\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
File "c:\program files\python 3.5\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\program files\python 3.5\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\program files\python 3.5\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\program files\python 3.5\lib\site-packages\PyInstaller\building\build_main.py", line 741, in build
os.makedirs(pth)
File "c:\program files\python 3.5\lib\os.py", line 241, in makedirs
mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\cms\\build\\cmstest
编辑:是的,脚本正在运行,脚本在 Win 10、Fedora 28 或使用 IDLE 上没有问题。
编辑:我得到一个 .spec 文件和一个空的 dist 文件夹
编辑:这是我的规范文件
block_cipher = None
a = Analysis(['cmsnewtest.py'],
pathex=['C:\\cms'],
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,
a.binaries,
a.zipfiles,
a.datas,
[],
name='cmsnewtest',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True ) `
Run Code Online (Sandbox Code Playgroud)
Kir*_*ito -3
对于 Windows,请尝试以下操作。我向您展示 python 3.7 的步骤。对于 python 3.5 也是同样的方法:
在 Windows 上安装 Python 3.7: https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe
在安装过程中勾选以下复选框:
设置python环境变量很重要!没有这个 python 就无法正确运行像 pyinstaller 这样的包!我和你有同样的问题。
安装后启动 cmd 提示符并运行以下命令: pip install pyinstaller
打开 cmd promt 和 naivgate 到 .py 文件并运行 pyinstaller 例如:
cd C:\users\admin\desktop\pythonscriptfolder\
pyinstaller somepythonscript.py
归档时间: |
|
查看次数: |
2992 次 |
最近记录: |