Pycharm+PyQt5+Python3.5开发环境配置(详细教程)

简介: Pycharm+PyQt5+Python3.5开发环境配置(详细教程)

1 Pycharm安装

自行查阅资料,这个内容比较多,这里不再赘述了~

2 Python3.5安装

1. 下载
官网下载地址
2. 选择3.5(根据自身系统选择)版本下载
在这里插入图片描述
在这里插入图片描述
3. 下载完成,直接双击运行,即可,安装路径可选。
(注意:在双击运行后,打开安装程序界面,建议选择“增加环境变量”)
在这里插入图片描述
4. 环境变量设置
如果步骤3已经勾选了“增加环境变量”的话,就不用再设置环境变量。如果没有勾选,环境变量设置方法如下:
找到自己的Python3.5的安装路径(例如我的是:D:\Python 3.5),把以下几个路径添加到系统环境变量中。
①计算机--邮件--属性,打开如下界面:
在这里插入图片描述
②点击“高级系统设置”,再点击“环境变量”,如下:

    ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/2019111314592795.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L05vYW1hTmVsc29u,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20191113145935475.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L05vYW1hTmVsc29u,size_16,color_FFFFFF,t_70)

③在系统变量中找到path,双击打开path,然后再路径的最末尾加入:
Python的路径,要以“;”隔开,即可:
D:\Python35; D:\Python35\Lib; D:\Python35\Scripts;

        ![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20191113145959922.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L05vYW1hTmVsc29u,size_16,color_FFFFFF,t_70)

④验证Python是否安装成功,开始---输入“cmd”,回车打开命令行,输入:Python,看到如下界面就表示Python安装成功。
在这里插入图片描述

3 Pip安装

以上安装python3.5的时候,默认已经安装了pip工具,这里直接升级pip到最新即可。

python -m install --upgrade pip

4 PyQt5安装

pip install pyqt5
pip install pyqt5-tools

5 Pycharm中编译工具设置及pyqt5包的导入

  • 新建一个项目
  • Ctrl+Alt+S,打开设置界面,点击项目下的“Project Interpreter”

在这里插入图片描述

  • 点击如图的设置按钮

在这里插入图片描述

  • 点击“Add...”

在这里插入图片描述

  • 设置编译工具python.exe,具体根据自己的路径选择

在这里插入图片描述

  • 此时会自动导入编译工具下的包

- dsd

6 指定Qt Designer

  • Ctrl+Alt+S,打开设置界面,点击“工具-外部工具”,点击“+”

在这里插入图片描述

  • 设置参数如下:

在这里插入图片描述
① program:

D:\Python 3.5\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe,(换成自己的目录即可)

②arguments:

$FileDir$\$FileName$ 

③working directory:

$FileDir$

7 指定PyUIC5

  • 步骤和添加Qt Designer一模一样
  • 作用:把qt的UI文件转换成.py文件的工具
  • 具体参数如下:

在这里插入图片描述

① program:

D:\Python 3.5\Scripts\pyuic5.exe(换成自己的目录即可)

②arguments:

$FileName$ -o $FileNameWithoutExtension$.py

③working directory:

$FileDir$

8 指定PyRcc5

  • 步骤和添加PyUIC5一模一样
  • 作用:将资源文件如图片等转成python代码能识别的文件
  • 具体参数如下:

在这里插入图片描述

① program:

D:\Python 3.5\Scripts\pyrcc5.exe(换成自己的目录即可)

②arguments:

$FileName$ -o $FileNameWithoutExtension$.py

③working directory:

$FileDir$

9 PyInstaller安装

  • 作用:打包命令:cmd控制台到F:\Python 3.5\Scripts路径下,输入命令 pyinstaller.exe -F f:\prj\hello.py,

即可生成一个hello.exe独立的执行文件;不使用-F命令将会一同生成依赖库

  • 安装指令:
pip3 install pyinstaller

10 查看是否配置OK

在Pycharm主界面,点击“工具-外部工具”,就可以看到自己添加的几个外部工具了
在这里插入图片描述

11 简单写一个程序预热下

  • 打开QT designer,设计如下一个UI图:

- sdsd

  • 然后点击保存,或者另存到项目的目录,如:UI文件为untitled.ui
  • 在untitled.ui文件右键,external tools->pyuic5,生成py代码,生成untitled.py
  • 在该项目下另外再新建一个py文件test.py用于运行调用untitled.py

12 untitled.py

# -*- coding: utf-8 -*-

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
        self.textEdit.setGeometry(QtCore.QRect(180, 50, 441, 411))
        self.textEdit.setObjectName("textEdit")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23))
        self.menubar.setObjectName("menubar")
        self.menutes = QtWidgets.QMenu(self.menubar)
        self.menutes.setObjectName("menutes")
        MainWindow.setMenuBar(self.menubar)
        self.menubar.addAction(self.menutes.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.textEdit.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                            _ooOoo_  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                           o8888888o  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                          88  .  88  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                           (| -_- |)  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                            O\\\\ = /O  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                        ____/`---\'\\\\____ </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                     .   \' \\\\| |// `. </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                       / \\\\||| : |||// \\\\  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                     / _||||| -:- |||||- \\\\ </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                       | | \\\\\\\\\\\\ - /// | |  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                     | \\\\_| \'\'\\\\---/\'\' | |  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                      \\\\ .-\\\\__ `-` ___/-. /  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                   ___`. .\' /--.--\\\\ `. . __  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                ."" \'< `.___\\\\_<|>_/___.\' >\'"".  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">               | | : `- \\\\`.;`\\\\ _ /`;.`/ - ` : | |  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                 \\\\ \\\\ `-. \\\\_ __\\\\ /__ _/ .-` / /  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">         ======`-.____`-.___\\\\_____/___.-`____.-\'======  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                            `=---=\'  ")</p>\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">           .............................................  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                 佛祖镇楼                  BUG辟易</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">          佛曰:  </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                  写字楼里写字间,写字间里程序员;</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                  程序人员写程序,又拿程序换酒钱。 </p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                  酒醒只在网上坐,酒醉还来网下眠;</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                  酒醉酒醒日复日,网上网下年复年。</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">                  但愿老死电脑间,不愿鞠躬老板前; </p></body></html>"))
        self.menutes.setTitle(_translate("MainWindow", "Testing"))

13 test.py

import sys
import untitled
from PyQt5 import QtWidgets
#from PyQt5.QtWidgets import QApplication,QMainWindow
from untitled import Ui_MainWindow


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = untitled.Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

14 直接运行test.py,即可

在这里插入图片描述

目录
相关文章
|
4月前
|
监控 安全 程序员
Python日志模块配置:从print到logging的优雅升级指南
从 `print` 到 `logging` 是 Python 开发的必经之路。`print` 调试简单却难维护,日志混乱、无法分级、缺乏上下文;而 `logging` 支持级别控制、多输出、结构化记录,助力项目可维护性升级。本文详解痛点、优势、迁移方案与最佳实践,助你构建专业日志系统,让程序“有记忆”。
382 0
|
10月前
|
人工智能 IDE 开发工具
JetBrains PyCharm 2025.1 发布 - 面向专业开发者的 Python IDE
JetBrains PyCharm 2025.1 (macOS, Linux, Windows) - 面向专业开发者的 Python IDE
1088 29
JetBrains PyCharm 2025.1 发布 - 面向专业开发者的 Python IDE
|
5月前
|
JSON 缓存 开发者
淘宝商品详情接口(item_get)企业级全解析:参数配置、签名机制与 Python 代码实战
本文详解淘宝开放平台taobao.item_get接口对接全流程,涵盖参数配置、MD5签名生成、Python企业级代码实现及高频问题排查,提供可落地的实战方案,助你高效稳定获取商品数据。
|
6月前
|
JavaScript 前端开发 机器人
【Azure Bot Service】在中国区Azure上部署机器人的 Python 版配置
本文介绍了在中国区Azure上使用Python SDK配置Azure Bot Service时遇到的问题及解决方案,涵盖参数设置与适配器配置,适用于希望在Azure中国区部署Python机器人的开发者。
187 6
|
10月前
|
IDE 开发工具 开发者
手把手教你安装PyCharm 2025:开发者的Python IDE配置全流程+避坑指南
本教程详细介绍了PyCharm 2025版本在Windows系统下的安装流程及配置方法,涵盖AI代码补全与智能调试工具链等新功能。内容包括系统要求、安装步骤、首次运行配置(如主题选择与插件安装)、创建首个Python项目,以及常见问题解决方法。此外,还提供了切换中文界面和延伸学习资源的指导,帮助用户快速上手并高效使用PyCharm进行开发。
5222 61
|
9月前
|
Python
在VScode环境下配置Python环境的方法
经过上述步骤,你的VSCode环境就已经配置好了。请尽情享受这扇你为自己开启的知识之窗。如同你在冒险世界中前行,你的探索之路只有越走越广,你获得的知识只会越来越丰富,你的能力只会越来越强。
859 37
|
10月前
|
存储 监控 API
【Azure App Service】分享使用Python Code获取App Service的服务器日志记录管理配置信息
本文介绍了如何通过Python代码获取App Service中“Web服务器日志记录”的配置状态。借助`azure-mgmt-web` SDK,可通过初始化`WebSiteManagementClient`对象、调用`get_configuration`方法来查看`http_logging_enabled`的值,从而判断日志记录是否启用及存储方式(关闭、存储或文件系统)。示例代码详细展示了实现步骤,并附有执行结果与官方文档参考链接,帮助开发者快速定位和解决问题。
302 22
|
IDE 测试技术 项目管理
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
PyCharm是由JetBrains开发的Python集成开发环境(IDE),专为Python开发者设计,支持Web开发、调试、语法高亮、项目管理、代码跳转、智能提示、自动完成、单元测试和版本控制等功能。它有专业版、教育版和社区版三个版本,其中社区版免费且适合个人和小型团队使用,包含基本的Python开发功能。安装PyCharm前需先安装Python解释器,并配置环境变量。通过简单的步骤即可在PyCharm中创建并运行Python项目,如输出“Hello World”。
4561 13
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
|
IDE 网络安全 开发工具
IDE之pycharm:专业版本连接远程服务器代码,并配置远程python环境解释器(亲测OK)。
本文介绍了如何在PyCharm专业版中连接远程服务器并配置远程Python环境解释器,以便在服务器上运行代码。
5285 0
IDE之pycharm:专业版本连接远程服务器代码,并配置远程python环境解释器(亲测OK)。

热门文章

最新文章

推荐镜像

更多