Skip to content

下载python版本

https://www.python.org/downloads/

查看版本

python --version

pip --version

安装python依赖

pip install xxxxxxxx

列表项目中的依赖项目

pip list

将项目依赖列表写入到requirements.txt

pip freeze > requirements.txt

运行python文件

python xxxx.py

将python api 用服务进行承载

[Unit]
Description=My Python API Service
After=network.target

[Service]
ExecStart=/usr/bin/python3 /path/to/your/python/api.py
Restart=always
User=yourusername
Group=yourusername
Environment=PATH=/usr/bin:/usr/local/bin
Environment=PYTHONPATH=/path/to/your/python/
WorkingDirectory=/path/to/your/python/

[Install]
WantedBy=multi-user.target