事情由来
今天帮朋友用python写了个小脚本,知道python可以利用pyinstaller打包成exe,直接pip3 install pyinstaller 安装好了pyinstaller,然后pyinstaller -F -w xxx.py ,就去上了趟厕所,拿起纸巾。。。本以为应该早就打包好的exe结果等来的是 command not found ,WTF!
解决方法
上网查了很久归根结底就是Mac上环境变量的设置问题
- 找到pyinstaller的快捷方式目录
/Library/Frameworks/Python.framework/Versions/3.7/bin - 将目录添加环境变量目录
编辑环境变量文件
sudo vi ~/.bash_profile
添加一行:
export PATH=${PATH}:/Library/Frameworks/Python.framework/Versions/3.7/bin
退出vim,执行以下命令
source .bash_profile
命令行输入pyinstaller出现以下,恭喜你成功了!
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME]
[--add-data <SRC;DEST or SRC:DEST>]
[--add-binary <SRC;DEST or SRC:DEST>] [-p DIR]
[--hidden-import MODULENAME]
[--collect-submodules MODULENAME]
[--collect-data MODULENAME] [--collect-binaries MODULENAME]
[--collect-all MODULENAME] [--copy-metadata PACKAGENAME]
[--recursive-copy-metadata PACKAGENAME]
[--additional-hooks-dir HOOKSPATH]
[--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES]
[--key KEY] [--splash IMAGE_FILE]
[-d {all,imports,bootloader,noarchive}] [-s] [--noupx]
[--upx-exclude FILE] [-c] [-w]
[-i <FILE.ico or FILE.exe,ID or FILE.icns or "NONE">]
[--disable-windowed-traceback] [--version-file FILE]
[-m <FILE or XML>] [-r RESOURCE] [--uac-admin]
[--uac-uiaccess] [--win-private-assemblies]
[--win-no-prefer-redirects]
[--osx-bundle-identifier BUNDLE_IDENTIFIER]
[--target-architecture ARCH] [--codesign-identity IDENTITY]
[--osx-entitlements-file FILENAME] [--runtime-tmpdir PATH]
[--bootloader-ignore-signals] [--distpath DIR]
[--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a]
[--clean] [--log-level LEVEL]
scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname
|