PyQt5基础 使用conda创建开发环境

215 阅读2分钟
  •        Python : 3.8.13
  •          OS : Windows 21H1
  •       Conda : 4.11.0
  •     PyCharm : 2021.2.3 (Community Edition)

代码

C:\Users\admin>conda create -n pyqtenv python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.11.0
  latest version: 4.12.0

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: D:\Develop\Anaconda3\envs\pyqtenv

  added / updated specs:
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2021.10.8          |   py38haa95532_2         152 KB
    pip-21.2.2                 |   py38haa95532_0         1.9 MB
    python-3.8.13              |       h6244533_0        16.5 MB
    setuptools-61.2.0          |   py38haa95532_0         1.0 MB
    wincertstore-0.2           |   py38haa95532_2          15 KB
    ------------------------------------------------------------
                                           Total:        19.5 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2022.3.29-haa95532_1
  certifi            pkgs/main/win-64::certifi-2021.10.8-py38haa95532_2
  openssl            pkgs/main/win-64::openssl-1.1.1n-h2bbff1b_0
  pip                pkgs/main/win-64::pip-21.2.2-py38haa95532_0
  python             pkgs/main/win-64::python-3.8.13-h6244533_0
  setuptools         pkgs/main/win-64::setuptools-61.2.0-py38haa95532_0
  sqlite             pkgs/main/win-64::sqlite-3.38.2-h2bbff1b_0
  vc                 pkgs/main/win-64::vc-14.2-h21ff451_1
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
  wheel              pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py38haa95532_2


Proceed ([y]/n)?

done
#
# To activate this environment, use
#
#     $ conda activate pyqtenv
#
# To deactivate an active environment, use
#
#     $ conda deactivate

C:\Users\admin>conda activate pyqtenv

(pyqtenv) C:\Users\admin>pip list
Package      Version
------------ ---------
certifi      2021.10.8
pip          21.2.2
setuptools   61.2.0
wheel        0.37.1
wincertstore 0.2

(pyqtenv) C:\Users\admin>
(pyqtenv) C:\Users\admin>pip install PyQt5
Collecting PyQt5
  Downloading PyQt5-5.15.6-cp36-abi3-win_amd64.whl (6.7 MB)
     |████████████████████████████████| 6.7 MB 1.3 MB/s
Collecting PyQt5-sip<13,>=12.8
  Downloading PyQt5_sip-12.10.1-cp38-cp38-win_amd64.whl (77 kB)
     |████████████████████████████████| 77 kB 394 kB/s
Collecting PyQt5-Qt5>=5.15.2
  Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)
     |████████████████████████████████| 50.1 MB 819 kB/s
Installing collected packages: PyQt5-sip, PyQt5-Qt5, PyQt5
Successfully installed PyQt5-5.15.6 PyQt5-Qt5-5.15.2 PyQt5-sip-12.10.1

(pyqtenv) C:\Users\admin>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5_tools
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyqt5_tools
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB)
Collecting pyqt5-plugins<5.15.4.3,>=5.15.4.2.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/ec/316eda19c30c925e2b356dcf4fc27cd2301e2242f68ae9ab937f81f31a3b/pyqt5_plugins-5.15.4.2.2-cp38-cp38-win_amd64.whl (67 kB)
     |████████████████████████████████| 67 kB 564 kB/s
Collecting python-dotenv
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Collecting click
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl (96 kB)
     |████████████████████████████████| 96 kB 520 kB/s
Collecting pyqt5==5.15.4
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9e/53/9476464c2a8db5252de96fd8ff39ec5db6ef09b8a08a7152546b7f142d90/PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB)
     |████████████████████████████████| 6.8 MB 363 kB/s
Requirement already satisfied: PyQt5-sip<13,>=12.8 in d:\develop\anaconda3\envs\pyqtenv\lib\site-packages (from pyqt5==5.15.4->pyqt5_tools) (12.10.1)
Requirement already satisfied: PyQt5-Qt5>=5.15 in d:\develop\anaconda3\envs\pyqtenv\lib\site-packages (from pyqt5==5.15.4->pyqt5_tools) (5.15.2)
Collecting qt5-tools<5.15.2.2,>=5.15.2.1.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ea/be/eb688ba4a5f8ddd3a26c2a49f7f4b408c1e504081c7c36fe20befeb6bea0/qt5_tools-5.15.2.1.2-py3-none-any.whl (13 kB)
Collecting qt5-applications<5.15.2.3,>=5.15.2.2.2
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/08/5b/d8aa1ed54236c6d676ad24fa3f81c759075c2226b510b3386f80218473d1/qt5_applications-5.15.2.2.2-py3-none-win_amd64.whl (60.9 MB)
     |████████████████████████████████| 60.9 MB 7.8 kB/s
Collecting click
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 66 kB/s
Installing collected packages: qt5-applications, click, qt5-tools, pyqt5, python-dotenv, pyqt5-plugins, pyqt5-tools
  Attempting uninstall: pyqt5
    Found existing installation: PyQt5 5.15.6
    Uninstalling PyQt5-5.15.6:
      Successfully uninstalled PyQt5-5.15.6
Successfully installed click-7.1.2 pyqt5-5.15.4 pyqt5-plugins-5.15.4.2.2 pyqt5-tools-5.15.4.3.2 python-dotenv-0.20.0 qt5-applications-5.15.2.2.2 qt5-tools-5.15.2.1.2

(pyqtenv) C:\Users\admin>
(pyqtenv) C:\Users\admin>pip list
Package          Version
---------------- ----------
certifi          2021.10.8
click            7.1.2
pip              21.2.2
PyQt5            5.15.4
pyqt5-plugins    5.15.4.2.2
PyQt5-Qt5        5.15.2
PyQt5-sip        12.10.1
pyqt5-tools      5.15.4.3.2
python-dotenv    0.20.0
qt5-applications 5.15.2.2.2
qt5-tools        5.15.2.1.2
setuptools       61.2.0
wheel            0.37.1
wincertstore     0.2

(pyqtenv) C:\Users\admin>conda deactivate

学习推荐


Python具有开源、跨平台、解释型和交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
GUI可以选择Tkinter、PySide2、wxPython、PyGObject、wxWidgets等进行创作。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。