本文主要是介绍poetry执行报错 Reason: tried: ‘/opt/homebrew/Cellar/python@x.x,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错如下:
➜ poetry shell
➜ poetry run uvicorn main:app --reload --port 7000
dyld[42259]: Library not loaded: /opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/PythonReferenced from: <63F55A2A-2EB4-35B8-9170-973C0E2BDAE0> /Users/guojianbo/Library/Application Support/pypoetry/venv/bin/pythonReason: tried: '/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/opt/homebrew/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file), '/System/Library/Frameworks/Python.framework/Versions/3.9/Python' (no such file, not in dyld cache)
[1] 42259 abort poetry run uvicorn main:app --reload --port 7000
(base)
解决方法:
- 查看当前 poetry 命令路径:
➜ which poetry
/Users/guojianbo/.local/bin/poetry
- 打开 /Users/guojianbo/.local/bin/poetry 文件
#!/bin/sh
'''exec' "/Users/guojianbo/Library/Application Support/pypoetry/venv/bin/python" "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from poetry.console.application import main
if __name__ == '__main__':sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])sys.exit(main())
看看报错信息可以发现是 /Users/guojianbo/Library/Application Support/pypoetry/venv/bin/python 路径的问题。
- 查看你当前 python 的路径
➜ which python3
/Users/guojianbo/anaconda3/bin/python3
- 将路径改成你当前使用 python 的路径
# 修改这一行即可
'''exec' "/Users/guojianbo/anaconda3/bin/python3" "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from poetry.console.application import main
if __name__ == '__main__':sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])sys.exit(main())
再次运行 poetry run
命令, 可以看见成功运行了:
➜ poetry run uvicorn main:app --reload --port 7000
INFO: Will watch for changes in these directories: ['/Users/guojianbo/Documents/github/screenshot-to-code/backend']
INFO: Uvicorn running on http://127.0.0.1:7000 (Press CTRL+C to quit)
INFO: Started reloader process [47018] using StatReload
INFO: Started server process [47024]
INFO: Waiting for application startup.
INFO: Application startup complete.
^CINFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [47024]
INFO: Stopping reloader process [47018]
(base)
这篇关于poetry执行报错 Reason: tried: ‘/opt/homebrew/Cellar/python@x.x的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!