我正在尝试使用pyinstaller使用以下命令创建可执行文件:
pyinstaller <script>.py
它在Linux上运行良好,但是在Windows上似乎不起作用。
Python : 3.5
Pyinstaller : 3.4
但是由于系统找不到指定的路径,它总是不断抛出错误: 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 ) `
答案 0 :(得分:0)
对于Windows,请尝试以下操作。我用python 3.7向您展示了stepts。对于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