Py系列
===================================
:锁定版本: 3.11.12
:生命周期: 2022-10-24 ~ 2027-10
:文档: https://docs.python.org/zh-cn/3.11/
:github地址: https://github.com/python/cpython
:版本生命周期: https://devguide.python.org/versions/
:参考: https://pythonguidecn.readthedocs.io/zh/latest/
:awesome-python: https://github.com/vinta/awesome-python
:awesome-python.cn: https://github.com/jobbole/awesome-python-cn
:视频教学: `黑马程序员python教程,8天python从入门到精通,学python看这套就够了 `_
:下载地址: https://www.python.org/downloads/
:风向标项目: django
.. seealso::
* 官方文档: https://docs.python.org/zh-cn/3.10/using/unix.html
* B站: `Linux系统上升级安装Python3.10 `_ (Centos)
* B站: `在Ubuntu服务器安装Python 3.10 `_
* 官网安装包: https://www.python.org/ftp/python/3.10.12/Python-3.10.16.tgz
安装python
.. tabs::
.. tab:: uv
https://docs.astral.sh/uv/guides/install-python/#installing-python
.. code-block:: console
$ uv python install 3.12
访问的官网,速度较慢,支持通过环境变量 `UV_PYTHON_INSTALL_MIRROR `_ 从指定文件安装
从 `release `_ 页面下载python包
可以先执行命令,从报错信息获取要下载的文件名称
.. code-block:: console
$ UV_PYTHON_INSTALL_MIRROR=file:///temp uv python install python3.12
error: Failed to install cpython-3.12.12-linux-x86_64-gnu
Caused by: failed to query metadata of file `/temp/20251014/cpython-3.12.12+20251014-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz`: No such file or directory (os error 2)
知道文件名称后,可以自己拼接url得到下载地址: https://github.com/astral-sh/python-build-standalone/releases/download/20251014/cpython-3.12.12+20251014-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
将文件放到 ``/tmp/20251015`` 目录下,重新执行命令
.. code-block:: console
$ UV_PYTHON_INSTALL_MIRROR=file:///tmp uv python install python3.12
Installed Python 3.12.12 in 982ms
+ cpython-3.12.12-linux-x86_64-gnu (python3.11)
warning: `/root/.local/bin` is not on your PATH. To use installed Python executables, run `export PATH="/root/.local/bin:$PATH"` or `uv python update-shell`.
.. tab:: 源码构建Python
在root账号操作
官网下载慢,建议在镜像源下载: https://registry.npmmirror.com/binary.html?path=python/
.. code-block:: console
$ wget https://registry.npmmirror.com/-/binary/python/3.10.16/Python-3.10.16.tgz
$ tar -zxvf Python-3.10.16.tgz
$ cd Python-3.10.17/
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo apt-get install python-dev
$ sudo apt-get install libffi-dev
$ sudo apt-get install libssl-dev
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
$ ./configure --prefix=/usr/local/python3.10
$ make -j8
$ make altinstall
$ ./configure -C \
--with-openssl=/usr/local/custom-openssl \
--with-openssl-rpath=auto \
--prefix=/usr/local/python3.10
$ ln -s /usr/local/python3.10/bin/python3.10 /usr/local/bin/python3.10
$ ln -s /usr/local/python3.10/bin/pip3.10 /usr/local/bin/pip3.10
**加入环境变量(可选)**
编辑 :file:`~/.bashrc` 和 :file:`$HOME/.profile`
添加一行脚本
.. code-block:: shell
export PATH=$PATH:/usr/local/python3.10/bin/
**安装sqlite3**
解决无法import _sqlite3的问题
https://blog.csdn.net/line_on_database/article/details/116058659
**安装ssl**
解决无法import _ssl的问题
第一种: 升级openssl
操作步骤参考文档: https://docs.python.org/zh-cn/3.10/using/unix.html#custom-openssl
第二种: libressl
.. warning::
实践中,发现Python3.10仍然安装不了_ssl,3.10+只能使用openssl
https://blog.csdn.net/weixin_39703551/article/details/111795468
**缺失_lzma模块**
.. code-block:: console
$ apt-get install liblzma-dev -y
然后重新编译python
.. include:: django.rst
.. include:: ansible.rst
.. include:: pytest.rst
ai
-------------------------------------
sentence-transformers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 4.1.0(2025-04-15)
:github: https://github.com/UKPLab/sentence-transformers
:文档: https://www.sbert.net/index.html
在向量数据库召回重排打分时使用, 中文模型建议用BAAI/bge-reranker-large
ollama
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在本地运行大模型, 对硬件有一定的要求
:锁定版本: 0.6.5(2025-03-12 ~ 2025-04-06)
:github: https://github.com/ollama/ollama
.. seealso::
`Ollama 与 LM Studio,本地 AI 推理工具怎么选? `_
langchain
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.3.17(2024-09-14 ~ 2025-01-30)
:文档: https://python.langchain.com/docs/introduction/
:github: https://github.com/langchain-ai/langchain
langgraph
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.2.72(2024-08-07 ~ 2025-02-13)
:文档: https://langchain-ai.github.io/langgraph/
:github: https://www.github.com/langchain-ai/langgraph
langchain-openai
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.3.5(2025-01-11 ~ 2025-02-12)
:文档: https://python.langchain.com/docs/integrations/chat/openai/
:github: https://github.com/langchain-ai/langchain/tree/master/libs/partners/openai
openai
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 1.61.0(2025-02-01)
:文档: https://github.com/openai/openai-python/tree/main/api.md
:github: https://github.com/openai/openai-python
streamlit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
构建前端ui的玩具
:锁定版本: 1.41.1(2024-12-11 ~ 2024-12-14)
:文档: https://docs.streamlit.io/
:github: https://github.com/streamlit/streamlit
zhipuai
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(在嵌入模型使用)
:锁定版本: 2.1.5.20250106(2024-08-30 ~ 2025-01-06)
:文档: https://open.bigmodel.cn/dev/howuse/introduction
后端
-------------------------------------
Fastapi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.116.1(2025-07-07 ~ 2025-07-12)
:文档: https://fastapi.tiangolo.com/
:github: https://github.com/fastapi/fastapi
:风向标项目: https://github.com/fastapi/full-stack-fastapi-template
pydantic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.11.4(2025-03-28 ~ 2025-04-30)
:文档: https://docs.pydantic.dev/latest/
:github: https://github.com/pydantic/pydantic
:变更日志: https://docs.pydantic.dev/latest/changelog/
Pandas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.1.4(2023-08-30 ~ 2023-12-08)
:文档: https://pandas.pydata.org/docs/
:github: https://github.com/pandas-dev/pandas
ORM
----------------------------------
sqlalchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.0.36(2023-01-27 ~ 2024-10-16)
:文档: https://docs.sqlalchemy.org/
:github: https://docs.sqlalchemy.org/en/20/
sqlmodel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sqlalchemy的浅层封装
:锁定版本: 0.0.22(2021-08-24 ~ 2024-08-31)
:文档: https://sqlmodel.tiangolo.com
:github: https://github.com/fastapi/sqlmodel
sqlacodegen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.3.0.post1(2020-07-13 ~ 2023-03-06)
:github: https://github.com/agronholm/sqlacodegen
插件
----------------------------
pydantic-settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.7.0(2024-12-13)
:文档: https://docs.pydantic.dev/latest/concepts/pydantic_settings/
:github: https://github.com/pydantic/pydantic-settings
文档
----------------------------
sphinx-tabs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 3.4.7(2022-06-25 ~ 2024-10-08)
:文档: https://sphinx-tabs.readthedocs.io/
:github: https://github.com/executablebooks/sphinx-tabs
sphinx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 7.3.7(2024-4-17 ~ 2024-4-19)
:文档: https://www.sphinx-doc.org/
:github: https://github.com/sphinx-doc/sphinx
:变更日志: https://www.sphinx-doc.org/en/master/changes/index.html
sphinx-rtd-theme
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.0.0(2023-11-28)
:文档: https://sphinx-rtd-theme.readthedocs.io/en/stable/
:github: https://github.com/readthedocs/sphinx_rtd_theme
sphinx-autobuild
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2024.10.3(2024-10-03)
:文档: https://github.com/sphinx-doc/sphinx-autobuild?tab=readme-ov-file#sphinx-autobuild
:github: https://github.com/sphinx-doc/sphinx-autobuild
sphinx-copybutton
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.5.2(2022-02-06 ~ 2023-04-14)
:文档: https://sphinx-copybutton.readthedocs.io/en/latest/
:github: https://github.com/executablebooks/sphinx-copybutton
:最新版本: (2025-03-13)
运维
----------------------------
supervisor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 4.2.5(2020-05-01 ~ 2022-12-24)
:文档: http://supervisord.org/
:github: https://github.com/Supervisor/supervisor
:最新检查版本时间: 2025-08-02
buildbot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 3.11.9(2024-01-26 ~ 2024-10-14)
:文档: https://docs.buildbot.net/current/index.html
:github: https://github.com/buildbot/buildbot
模板
---------------------------------
jinja2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 3.1.5(2022-03-24 ~ 2024-12-22)
:文档: https://jinja.palletsprojects.com/
:github: https://github.com/pallets/jinja
:重要程度: ***
cookiecutter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.6.0(2024-02-22)
:文档: https://cookiecutter.readthedocs.io/en/stable/index.html
:github: https://github.com/cookiecutter/cookiecutter
* 提供从需求到落地的解决方案
* 工作环境的低代码工具
抽象企业项目代码风格,将开发思路模板起来, 然后根据实际业务填充业务代码(业务代码没办法模板)
例如excel导入
.. code-block:: python
@action
def imports(self, request, *args, **kwargs):
# 调用封装好的excel处理函数
pass
# ....
pass
# ...
pass
.. _cookiecutter-django:
cookiecutter-django
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2024.10.30(2024-10-30)
:文档: https://cookiecutter-django.readthedocs.io/en/latest
:github: https://github.com/cookiecutter/cookiecutter-django
http客户端
------------------------------
requests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.32.5(2024-05-20 ~ 2025-08-19)
:文档: https://requests.readthedocs.io/en/latest/
:github: https://github.com/psf/requests
:自定义文档: https://luzhenxiong.top/docs/django/guides/3rd-api.html
:关注的issue: `breaking aws s3 usage with requests 2.32.0 `_
有空去了解下 https://httpbin.org/
应用场景:
* 封装第三方接口, 示例: gitee的 `client.py `_
aiohttp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 3.11.7(2024-11-14 ~ 2024-11-21)
:文档: https://aiohttp.readthedocs.io/
:github: https://github.com/aio-libs/aiohttp
开发工具
---------------------------------
ipython
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 9.4.0(2025-07-01)
:文档: https://ipython.readthedocs.io/
:github: https://github.com/ipython/ipython
invoke
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make命令的平替工具
:锁定版本: 2.2.0(2023-07-13)
:文档: https://docs.pyinvoke.org/en/stable/
:github: https://github.com/pyinvoke/invoke
ipdb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.13.13(2020-2-28 ~ 2023-05-09)
:github: https://github.com/gotcha/ipdb
bpython
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.25(2025-01-17)
:文档: https://docs.bpython-interpreter.org/en/latest/index.html
:github: https://github.com/bpython/bpython
watchfiles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 1.0.4(2024-11-25 ~ 2025-01-10)
:文档: https://watchfiles.helpmanual.io/
:github: https://github.com/samuelcolvin/watchfiles
爬虫
----------------------------------
scrapyd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 1.6.0(2025-07-22)
:文档: https://scrapyd.readthedocs.io/
:github: https://github.com/scrapy/scrapyd
scrapyd-client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.0.3(2024-10-11 ~ 2025-05-23)
:github: https://github.com/scrapy/scrapyd-client
scrapy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.12.0(2024-11-18)
:文档: https://docs.scrapy.org/
:github: https://github.com/scrapy/scrapy
:变更日志: https://docs.scrapy.org/en/latest/news.html
:视频教程: https://www.bilibili.com/video/BV1gA4m1G7zk
scrapy-playwright
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 0.0.42(2024-11-06)
:github: https://github.com/scrapy-plugins/scrapy-playwright
:变更日志: https://pypi.org/project/scrapy-playwright/docs/changelog.md
beautifulsoup4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 4.13.3(2025-02-03 ~ 2025-02-05)
:文档: https://www.crummy.com/software/BeautifulSoup/bs4/doc/
异步任务
--------------------------------
celery-redbeat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
基于redis的调度器
:锁定版本: 2.3.3(2025-02-24 ~ 2025-07-02)
:文档: https://redbeat.readthedocs.io/en/latest/index.html
:github: https://github.com/sibson/redbeat
celery
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 5.5.3(2025-04-01 ~ 2025-06-01)
:文档: https://docs.celeryq.dev/en/stable/index.html
:github: https://github.com/celery/celery
:变更日志: https://docs.celeryq.dev/en/stable/changelog.html
django-celery-beat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.7.0(2024-08-22)
:文档: https://django-celery-beat.readthedocs.io/en/latest/
:github: http://github.com/celery/django-celery-beat
:变更日志: https://django-celery-beat.readthedocs.io/en/latest/changelog.html
:关注issue: https://github.com/celery/django-celery-beat/issues/798
flower
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 2.0.1(2023-06-18 ~ 2023-08-13)
:文档: https://flower.readthedocs.io/
:github: https://github.com/mher/flower
:最新确认: 2025-03-24
web服务
--------------------------------------
playwright
~~~~~~~~~~~~~~~~~~~~~
:锁定版本: 1.54.0(2025-07-22)
:文档: https://playwright.dev/python/docs/intro
:github: https://github.com/microsoft/playwright-python
gunicorn
~~~~~~~~~~~~~~~
:锁定版本: 23.0.0(2024-08-11)
:文档: https://docs.gunicorn.org/en/stable/
:github: https://github.com/benoitc/gunicorn
:变更日志: https://docs.gunicorn.org/en/stable/news.html