本页内容

配置 Python 开发环境

借助 Qt Python 扩展包,您可以使用 Qt for Python 应用程序:

  • 安装 PySide6 软件包
  • 使用Qt Quick 或基于Qt Widgets 的用户界面创建Qt for Python 应用程序
  • 构建、运行和清理应用程序
  • 使用debugpy 和QML调试器调试应用程序
  • 阅读Qt for Python 文档

为项目安装 PySide6

从 VS Code 运行 PySide6 项目的推荐方法是为每个项目单独安装 PySide6。当您首次为某个项目打开.py 文件时,VS Code 的 Qt 扩展会提示您执行此操作。

若需在后续为项目安装 PySide6:

  1. 转到“Command Palette ”,然后选择“Qt: Install PySide6 ”。
  2. 选择“Create environment ”为该项目创建新的虚拟环境。若要使用现有环境,请选择“Select environment ”。

使用 uv 创建虚拟环境

如果您已安装uvPython 包管理器并将其添加到 PATH 环境变量中,则可以使用它来创建虚拟环境:

  1. 转到“Command Palette ”,然后选择“Qt: Create virtual environment with uv ”。
  2. 选择“Create environment ”为项目创建新的虚拟环境。若要使用现有环境,请选择“Select environment ”。

另请参阅 “安装”、“教程:Qt Quick 和Qt for Python ”、“创建 Qt 项目”、“调试Qt for Python 应用程序”以及“阅读 Qt 文档”。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.