@TOC

Pycharm装置

装置教程

Python3.5装置

1. 下载
官网下载地址
2. 抉择3.5(依据本身零碎抉择)版本下载


3. 下载实现,间接双击运行,即可,装置门路可选。
(留神:在双击运行后,关上装置程序界面,倡议抉择“减少环境变量”)

4. 环境变量设置
如果步骤3曾经勾选了“减少环境变量”的话,就不必再设置环境变量。如果没有勾选,环境变量设置办法如下:
找到本人的Python3.5的装置门路(例如我的是:D:\Python 3.5),把以下几个门路增加到零碎环境变量中。
①计算机--邮件--属性,关上如下界面:

②点击“高级零碎设置”,再点击“环境变量”,如下:

    ![在这里插入图片形容](https://img-blog.csdnimg.cn/2019111314592795.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L05vYW1hTmVsc29u,size_16,color_FFFFFF,t_70)![在这里插入图片形容](https://img-blog.csdnimg.cn/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://img-blog.csdnimg.cn/20191113145959922.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L05vYW1hTmVsc29u,size_16,color_FFFFFF,t_70)

④验证Python是否装置胜利,开始---输出“cmd”,回车关上命令行,输出:Python,看到如下界面就示意Python装置胜利。

Pip装置

以上装置python3.5的时候,默认曾经装置了pip工具,这里间接降级pip到最新即可。

python -m install --upgrade pip

PyQt5装置

pip install pyqt5
pip install pyqt5-tools

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

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

  • 点击如图的设置按钮

  • 点击“Add...”
  • 设置编译工具python.exe,具体依据本人的门路抉择

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

## 指定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$

## 指定PyUIC5

  • 步骤和增加Qt Designer截然不同
  • 作用:把qt的UI文件转换成.py文件的工具
  • 具体参数如下:

① program:

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

②arguments:

$FileName$ -o $FileNameWithoutExtension$.py

③working directory:

$FileDir$

## 指定PyRcc5

  • 步骤和增加PyUIC5截然不同
  • 作用:将资源文件如图片等转成python代码能辨认的文件
  • 具体参数如下:

① program:

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

②arguments:

$FileName$ -o $FileNameWithoutExtension$.py

③working directory:

$FileDir$

## PyInstaller装置

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

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

  • 装置指令:
pip3 install pyinstaller

## 查看是否配置OK
在Pycharm主界面,点击“工具-内部工具”,就能够看到本人增加的几个内部工具了

## 简略写一个程序预热下

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

untitled.py

# -*- coding: utf-8 -*-from PyQt5 import QtCore, QtGui, QtWidgetsclass 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;\">                .&quot;&quot; \'&lt; `.___\\\\_&lt;|&gt;_/___.\' &gt;\'&quot;&quot;.  </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;\">                            `=---=\'  &quot;)</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"))

test.py

import sysimport untitledfrom PyQt5 import QtWidgets#from PyQt5.QtWidgets import QApplication,QMainWindowfrom untitled import Ui_MainWindowif __name__ == "__main__":    app = QtWidgets.QApplication(sys.argv)    MainWindow = QtWidgets.QMainWindow()    ui = untitled.Ui_MainWindow()    ui.setupUi(MainWindow)    MainWindow.show()    sys.exit(app.exec_())

间接运行test.py,即可