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,即可

在这里插入图片描述

目录
相关文章
|
11天前
|
JSON 数据可视化 API
Python 中调用 DeepSeek-R1 API的方法介绍,图文教程
本教程详细介绍了如何使用 Python 调用 DeepSeek 的 R1 大模型 API,适合编程新手。首先登录 DeepSeek 控制台获取 API Key,安装 Python 和 requests 库后,编写基础调用代码并运行。文末包含常见问题解答和更简单的可视化调用方法,建议收藏备用。 原文链接:[如何使用 Python 调用 DeepSeek-R1 API?](https://apifox.com/apiskills/how-to-call-the-deepseek-r1-api-using-python/)
|
22天前
|
IDE 测试技术 项目管理
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
PyCharm是由JetBrains开发的Python集成开发环境(IDE),专为Python开发者设计,支持Web开发、调试、语法高亮、项目管理、代码跳转、智能提示、自动完成、单元测试和版本控制等功能。它有专业版、教育版和社区版三个版本,其中社区版免费且适合个人和小型团队使用,包含基本的Python开发功能。安装PyCharm前需先安装Python解释器,并配置环境变量。通过简单的步骤即可在PyCharm中创建并运行Python项目,如输出“Hello World”。
197 13
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
|
25天前
|
安全 Linux 网络安全
利用Python脚本自动备份网络设备配置
通过本文的介绍,我们了解了如何利用Python脚本自动备份网络设备配置。该脚本使用 `paramiko`库通过SSH连接到设备,获取并保存配置文件。通过定时任务调度,可以实现定期自动备份,确保网络设备配置的安全和可用。希望这些内容能够帮助你在实际工作中实现网络设备的自动化备份。
51 14
|
29天前
|
人工智能 Java Python
python安装、vscode安装、conda安装:一文搞定Python的开发环境(史上最全)
尼恩架构团队推出了一系列《LLM大模型学习圣经》PDF,旨在帮助读者深入理解并掌握大型语言模型(LLM)及其相关技术。该系列包括Python基础、Transformer架构、LangChain框架、RAG架构及LLM智能体等内容,覆盖从理论到实践的各个方面。此外,尼恩还提供了配套视频教程,计划于2025年5月前发布,助力更多人成为大模型应用架构师,冲击年薪百万目标。
|
1月前
|
人工智能 编译器 Python
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
41 0
python已经安装有其他用途如何用hbuilerx配置环境-附带实例demo-python开发入门之hbuilderx编译器如何配置python环境—hbuilderx配置python环境优雅草央千澈
|
2月前
|
数据可视化 DataX Python
Seaborn 教程-绘图函数
Seaborn 教程-绘图函数
87 8
|
2月前
|
Python
Seaborn 教程-模板(Context)
Seaborn 教程-模板(Context)
57 4
|
2月前
Seaborn 教程-主题(Theme)
Seaborn 教程-主题(Theme)
155 7
|
2月前
|
数据可视化 Python
Seaborn 教程
Seaborn 教程
64 5
|
3月前
|
Python
SciPy 教程 之 Scipy 显著性检验 9
SciPy 教程之 Scipy 显著性检验第9部分,介绍了显著性检验的基本概念、作用及原理,通过样本信息判断假设是否成立。着重讲解了使用scipy.stats模块进行显著性检验的方法,包括正态性检验中的偏度和峰度计算,以及如何利用normaltest()函数评估数据是否符合正态分布。示例代码展示了如何计算一组随机数的偏度和峰度。
44 1

热门文章

最新文章

推荐镜像

更多