# PIP 操作与常用包的安装

# Python 虚拟环境使用

$ python -m venv venvname

# Windows 环境
PS .\venvname\Scripts\activate.ps1
PS deactivate

# Linux 环境
$ source ./venvname/bin/activate 
$ deactivate

# pip 安装

如果python安装完成后,没有pip,则需要手工安装pip。

$ curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py

# pip 升级

# 以下二者选其一 --upgrade 等价于 -U
$ python -m pip install --upgrade pip
$ python -m pip install -U pip

# pip 打开配置

$ pip config edit --editor notepad

配置文件格式

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple   	# 清华源
proxy = http://127.0.0.1:808							# Http代理
proxy = socks5://127.0.0.1:1080							# Socks5代理

# pip 更新包管理工具

$ pip install --upgrade setuptools

# pip 清除所有缓存

$ pip cache purge

# pip 换清华源

$ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# pip 安装 Requests 及 Socks 代理

$ pip install requests  
$ pip install pysocks

# pip 安装 Playwright

$ pip install playwright

# pip 安装 Pyinstaller

$ pip install pyinstaller

# pip 安装 PyQt5

$ pip install pyqt5
$ pip install pyqt5-tools

# pip 安装 qframelesswindow

$ pip install PyQt5-Frameless-Window

# pip 安装 OpenCV

$ pip install opencv-python 

# pip 安装 PIL

$ pip install Pillow

# pip 安装 pywin32

$ pip install pywin32

# pip 安装 Paddle

$ pip install paddlepaddle==2.3.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
$ pip install paddleocr>=2.0.1

# pip 安装 百度aip

$ pip install baidu-aip

# pip 安装 xlrd 1.2.0

$ pip install xlrd==1.2.0

# pip 安装 QT Frameless window

$ pip install PyQt5-Frameless-Window

# pip 安装 Scrcpy

$ pip install scrcpy-client[ui]

# pip 安装 MySql

$ pip install pymysql

# 如果安装后提示 No module named ‘mysql‘ 则执行以下指令
$ pip install mysql-connector

# pip 安装 Crypto

# 对老库无依赖
$ pip install pycryptodome

# 对老库有依赖
$ pip install pycryptodomex

# pip 安装 Tencent SDK

# 安装 common 泛型通用包
$ pip install -i mirrors.tencent.com --upgrade tencentcloud-sdk-python-common

# 安装 lighthouse 轻量应用服务器包
$ pip install -i mirrors.tencent.com --upgrade tencentcloud-sdk-python-lighthouse

# pip 安装 Flask

# 安装 Flask 框架
$ pip install flask

# 安装 Flask_CORS 跨域访问包
$ pip install flask_cors

# pip 安装 uWsgi

$ pip install uwsgi

# pip 安装 FindImage

$ pip install findimage

安装完成后如果报错,则需要对findimage文件进行修改:

ImportError: Bindings generation error. Submodule name should always start with a parent module name. Parent name: cv2.cv2. # Submodule name: cv2

# 将“site-packages\findimage\__init__.py”文件,第18行
from cv2 import cv2
# 改为
import cv2