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

在这里插入图片描述

目录
相关文章
|
10月前
|
数据采集 存储 XML
Python爬虫技术:从基础到实战的完整教程
最后强调: 父母法律法规限制下进行网络抓取活动; 不得侵犯他人版权隐私利益; 同时也要注意个人安全防止泄露敏感信息.
1085 19
|
9月前
|
索引 Python
Python 列表切片赋值教程:掌握 “移花接木” 式列表修改技巧
本文通过生动的“嫁接”比喻,讲解Python列表切片赋值操作。切片可修改原列表内容,实现头部、尾部或中间元素替换,支持不等长赋值,灵活实现列表结构更新。
437 1
|
10月前
|
数据采集 存储 JSON
使用Python获取1688商品详情的教程
本教程介绍如何使用Python爬取1688商品详情信息,涵盖环境配置、代码编写、数据处理及合法合规注意事项,助你快速掌握商品数据抓取与保存技巧。
|
12月前
|
机器学习/深度学习 数据安全/隐私保护 计算机视觉
过三色刷脸技术,过三色刷脸技术教程,插件过人脸python分享学习
三色刷脸技术是基于RGB三通道分离的人脸特征提取方法,通过分析人脸在不同颜色通道的特征差异
|
12月前
|
XML Linux 区块链
Python提取Word表格数据教程(含.doc/.docx)
本文介绍了使用LibreOffice和python-docx库处理DOC文档表格的方法。首先需安装LibreOffice进行DOC到DOCX的格式转换,然后通过python-docx读取和修改表格数据。文中提供了详细的代码示例,包括格式转换函数、表格读取函数以及修改保存功能。该方法适用于Windows和Linux系统,解决了老旧DOC格式文档的处理难题,为需要处理历史文档的用户提供了实用解决方案。
1336 1
|
11月前
|
并行计算 算法 Java
Python3解释器深度解析与实战教程:从源码到性能优化的全路径探索
Python解释器不止CPython,还包括PyPy、MicroPython、GraalVM等,各具特色,适用于不同场景。本文深入解析Python解释器的工作原理、内存管理机制、GIL限制及其优化策略,并介绍性能调优工具链及未来发展方向,助力开发者提升Python应用性能。
586 0
|
人工智能 搜索推荐 数据可视化
用 Python 制作简单小游戏教程:手把手教你开发猜数字游戏
本教程详细讲解了用Python实现经典猜数字游戏的完整流程,涵盖从基础规则到高级功能的全方位开发。内容包括游戏逻辑设计、输入验证与错误处理、猜测次数统计、难度选择、彩色输出等核心功能,并提供完整代码示例。同时,介绍了开发环境搭建及调试方法,帮助初学者快速上手。最后还提出了图形界面、网络对战、成就系统等扩展方向,鼓励读者自主创新,打造个性化游戏版本。适合Python入门者实践与进阶学习。
1419 1
|
11月前
|
数据采集 索引 Python
Python Slice函数使用教程 - 详解与示例 | Python切片操作指南
Python中的`slice()`函数用于创建切片对象,以便对序列(如列表、字符串、元组)进行高效切片操作。它支持指定起始索引、结束索引和步长,提升代码可读性和灵活性。
|
存储 算法 数据可视化
用Python开发猜数字游戏:从零开始的手把手教程
猜数字游戏是编程入门经典项目,涵盖变量、循环、条件判断等核心概念。玩家通过输入猜测电脑生成的随机数,程序给出提示直至猜中。项目从基础实现到功能扩展,逐步提升难度,适合各阶段Python学习者。
983 0

推荐镜像

更多