宝塔面板部署python项目

  1. 进入宝塔面板,安装Python项目管理器
    宝塔面板部署python项目_第1张图片

  2. 点击设置,点击添加项目
    宝塔面板部署python项目_第2张图片

  3. 填写项目信息
    Python版本初次选择前在版本管理处先安装环境。
    框架和启动方式此处选择flask和gunicorn。
    端口根据需求选择,记得在防火墙和安全组处开放相应的端口。宝塔面板部署python项目_第3张图片
    ps:可能遇到虚拟环境的问题。在终端cd到项目路径,输入:

    pip3 freeze > requirements.txt
    
  4. 点击模块,添加未自动导入的包宝塔面板部署python项目_第4张图片

  5. 点击"映射",映射到域名或者服务器公网ip宝塔面板部署python项目_第5张图片

  6. 关闭项目管理器,重新打开,检查服务器是否正常运行,如状态显示已暂停,检查日志。
    宝塔面板部署python项目_第6张图片
    如果日志中有No Module named xx的报错则在step5中添加相应的module。如果有TypeError: Descriptors cannot not be created directly.
    If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
    If you cannot immediately regenerate your protos, some other possible workarounds are:
    1.Downgrade the protobuf package to 3.20.x or lower.
    2.Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
    在终端中输入:

    pip3 uninstall protobuf
    pip3 install protobuf==3.19.0
    

    或者在step5中删除protobuf,再安装3.19.0的版本。protobuf版本在3.19.0以下即可。

你可能感兴趣的:(linux,python,flask,python)