當腳本py文件和PYTHON安裝目錄不在一起時锦针,執(zhí)行腳本會報:
import fastapi #需要在PY環(huán)境安裝fastapi包
/etc/profile添加環(huán)境變量PYTHONPATH:
export PYTHONPATH=$PYTHONPATH:/opt/Python-3.7.5/lib/site-packages
重新安裝fastapi柒桑,python默認不支持SSL丽惶,所以選用非HTTPS源:
pip install --target=/opt/Python-3.7.5/lib/site-packages fastapi[all] -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com