|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
打包py文件只有1行代码print("hello world")
排查过环境变量,没看出问题
完整报错:Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 33, in <module>
sys.exit(load_entry_point('pyinstaller==5.13.2', 'console_scripts', 'pyinstaller')())
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 194, in _console_script_run
run()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 180, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 61, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 1019, in main
build(specfile, distpath, workpath, clean_build)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 944, in build
exec(code, spec_namespace)
File "/Users/yy/Documents/interface/testPy/dyhProject1/base/in/demo17.spec", line 43, in <module>
entitlements_file=None,
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/api.py", line 582, in __init__
entitlements_file=self.entitlements_file
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/api.py", line 240, in __init__
self.__postinit__()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 184, in __postinit__
self.assemble()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/api.py", line 300, in assemble
strict_arch_validation=(typecode == 'EXTENSION'),
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/utils.py", line 219, in checkCache
digest = cacheDigest(fnm, redirects)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/utils.py", line 402, in cacheDigest
with open(fnm, "rb") as f:
IsADirectoryError: [Errno 21] Is a directory: '/usr/local/Python3'
跪求解决方案
根据你描述的错误和排查情况,我有几个可能的解决方案:
1. **重装PyInstaller和依赖项**:
尝试重新安装PyInstaller和所有相关依赖项,包括Python本身。
pip uninstall pyinstaller
pip install pyinstaller
2. **调整路径中的'python3'项**:
`PATH` 环境变量中有一项是 `/usr/local/bin/python3:`,它可能导致了问题。试着去掉或调整这项。
用如下命令移除 `PATH` 中的 `python3` 条目:
export PATH=$(echo $PATH | sed -e 's|:/usr/local/bin/python3||')
3. **检查软链接和文件权限**:
确认 `/usr/local/bin/python3` 是否真的指向一个可执行文件,而非一个目录。
使用下面的命令检查:
ls -l /usr/local/bin/python3
如果链接有问题,尝试重新创建链接:
sudo ln -sf $(which python3) /usr/local/bin/python3
4. **尝试不使用虚拟环境**:
有时候虚拟环境可能会导致问题。尝试在不使用虚拟环境的情况下打包。
5. **使用明确的文件路径**:
确保 `spec` 文件中使用的文件路径是明确和正确的。
检查一下 `spec` 文件 `/Users/yy/Documents/interface/testPy/dyhProject1/base/in/demo17.spec`,在命令中传递完整路径:
pyinstaller /Users/yy/Documents/interface/testPy/dyhProject1/base/in/demo17.spec
6. **在干净的环境中进行测试**:
创建一个新的虚拟环境,然后重新安装所需的包,再次尝试打包。
python3 -m venv newenv
source newenv/bin/activate
pip install pyinstaller
pyinstaller /path/to/your_script.py
这些步骤应该可以帮助你解决问题。如果问题依然存在,建议提供更多的环境信息或者尝试更详细的调试。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
|
|