python - PyInstaller Winerror3:系统找不到指定的路径
问题描述
我正在尝试使用 pyinstaller 使用以下命令创建可执行文件:
pyinstaller <script>.py
它在 Linux 中运行良好,但不知何故这似乎不适用于 Windows。
Python : 3.5
Pyinstaller : 3.4
但它不断抛出错误,系统找不到指定的路径:C:\folder\build\scriptname
而 build 文件夹通常是在执行 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 ) `
解决方案
对于 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 并导航到 .py 文件并运行 pyinstaller,例如:
cd C:\users\admin\desktop\pythonscriptfolder\
pyinstaller somepythonscript.py
推荐阅读
- python - 将 seaborn clustermap 嵌入到 tkinter 窗口中
- python - Python Request 得到 403 响应,但 Curl 得到 200 响应,这是怎么回事?
- php - 仅当是分组产品的一部分时才从循环中隐藏单个产品
- tensorflow - 错误:tensorflow 1.13.0rc2 要求 tensorboard<1.13.0,>=1.12.0,但您将拥有不兼容的 tensorboard 1.14.0
- javascript - addEvenetListener 不是函数
- python - Ray 本地集群 web-ui 显示 0 个工作人员
- node.js - MERN 堆栈电子邮件确认
- android - Firestore 从子集合中获取所有文档
- python - 列表和元组/列表之间的比较
- javascript - 使用 JS 和 SCSS 的导航动画,你能告诉我哪里出错了吗?