报错如下:
xxxx/.venv/bin/python -m uvicorn main:app --reload --proxy-headers --forwarded-allow-ips='*'
INFO: Will watch for changes in these directories: ['xxxxx路径']
ERROR: [Errno 48] Address already in use
一条命令杀死占用某某端口的指令
lsof -i :程序占用的端口号 | awk 'NR==2 {print $2}' | xargs kill -9
因为pycharm会默认使用8000作为uvicorn的测试端口, 所以实际命令是这样的:
lsof -i :8000 | awk 'NR==2 {print $2}' | xargs kill -9