Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Docs 菜单
Docs 主页
/ / /
Pymongo 驱动程序
/

兼容性

以下兼容性表指定了与特定版本的 MongoDB 一起使用的推荐版本或 PyMongo 版本。

第一列列出驱动程序版本。

重要

v4.4 生命周期结束

V4.4 已于 2024 年 2 月 29 日到期,MongoDB 不再提供支持。

平台
架构
版本
8.0
7.0
6.0
5.0
4.4

Amazon Linux 2023

x86_64

Enterprise

Amazon Linux 2023

x86_64

Community

Amazon Linux V2

x86_64

Enterprise

Amazon Linux V2

x86_64

Community

Debian 12

x86_64

Enterprise

Debian 12

x86_64

Community

Debian 11

x86_64

Enterprise

5.0.8+

Debian 11

x86_64

Community

5.0.8+

Debian 10

x86_64

Enterprise

Debian 10

x86_64

Community

Debian 9

x86_64

Enterprise

Debian 9

x86_64

Community

RHEL/Rocky/Alma/ Oracle Linux 9.0+ [2]

x86_64

Enterprise

6.0.4+

RHEL/Rocky/Alma/ Oracle Linux 9.0+ [2]

x86_64

Community

6.0.4+

RHEL/Rocky/Alma/ Oracle Linux 8.0+ [2]

x86_64

Enterprise

RHEL/Rocky/Alma/ Oracle Linux 8.0+ [2]

x86_64

Community

RHEL/ CentOS/ Oracle Linux 7.0+ [2]

x86_64

Enterprise

RHEL/ CentOS/ Oracle Linux 7.0+ [2]

x86_64

Community

RHEL/ CentOS/ Oracle Linux 6.2+ [2]

x86_64

Enterprise

RHEL/ CentOS/ Oracle Linux 6.2+ [2]

x86_64

Community

SLES 15

x86_64

Enterprise

SLES 15

x86_64

Community

SLES 12

x86_64

Enterprise

SLES 12

x86_64

Community

Ubuntu 24.04

x86_64

Enterprise

Ubuntu 24.04

x86_64

Community

Ubuntu 22.04

x86_64

Enterprise

6.0.4+

Ubuntu 22.04

x86_64

Community

6.0.4+

Ubuntu 20.04

x86_64

Enterprise

Ubuntu 20.04

x86_64

Community

Ubuntu 18.04

x86_64

Enterprise

Ubuntu 18.04

x86_64

Community

Ubuntu 16.04

x86_64

Enterprise

Ubuntu 16.04

x86_64

Community

Windows 11

x86_64

Enterprise

Windows 11

x86_64

Community

Windows Server 2022

x86_64

Enterprise

Windows Server 2022

x86_64

Community

Windows Server 2019

x86_64

Enterprise

Windows Server 2019

x86_64

Community

Windows 10 / Server 2016

x86_64

Enterprise

Windows 10 / Server 2016

x86_64

Community

macOS 14

x86_64

Enterprise

macOS 14

x86_64

Community

macOS 13

x86_64

Enterprise

macOS 13

x86_64

Community

macOS 12

x86_64

Enterprise

macOS 12

x86_64

Community

macOS 11

x86_64

Enterprise

macOS 11

x86_64

Community

macOS 10.15

x86_64

Enterprise

macOS 10.15

x86_64

Community

macOS 10.14

x86_64

Enterprise

macOS 10.14

x86_64

Community

macOS 10.13

x86_64

Enterprise

macOS 10.13

x86_64

Community

macOS 14

arm64

Enterprise

macOS 14

arm64

Community

macOS 13

arm64

Enterprise

macOS 13

arm64

Community

macOS 12

arm64

Enterprise

macOS 12

arm64

Community

macOS 11

arm64

Enterprise

macOS 11

arm64

Community

Amazon Linux 2023

arm64

Enterprise

Amazon Linux 2023

arm64

Community

Amazon Linux 2

arm64

Enterprise

4.4.4+

Amazon Linux 2

arm64

Community

4.4.4+

RHEL/CentOS/Rocky/Alma 9

arm64

Enterprise

RHEL/CentOS/Rocky/Alma 9

arm64

Community

RHEL/CentOS/Rocky/Alma 8

arm64

Enterprise

4.4.4+

RHEL/CentOS/Rocky/Alma 8

arm64

Community

4.4.4+

Ubuntu 24.04

arm64

Enterprise

Ubuntu 24.04

arm64

Community

Ubuntu 22.04

arm64

Enterprise

6.0.4+

Ubuntu 22.04

arm64

Community

6.0.4+

Ubuntu 20.04

arm64

Enterprise

Ubuntu 20.04

arm64

Community

Ubuntu 18.04

arm64

Enterprise

Ubuntu 18.04

arm64

Community

Ubuntu 16.04

arm64

Enterprise

RHEL/Rocky/Alma 9

ppc64le

Enterprise

RHEL/Rocky/Alma 8

ppc64le

Enterprise

RHEL/CentOS 7

ppc64le

Enterprise

6.0.7+

RHEL/Rocky/Alma 9

s390x

Enterprise

RHEL/Rocky/Alma 8

s390x

Enterprise

5.0.9+

RHEL/CentOS 7

s390x

Enterprise

RHEL/CentOS 7

s390x

Community

[2](1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 在Oracle Linux上, MongoDB仅支持 Red Hat Compatible Kernel。

重要

v4.4 生命周期结束

V4.4 已于 2024 年 2 月 29 日到期,MongoDB 不再提供支持。

平台
架构
版本
8.0
7.0
6.0
5.0
4.4

Amazon Linux 2023

x86_64

Enterprise

Amazon Linux 2023

x86_64

Community

Amazon Linux V2

x86_64

Enterprise

Amazon Linux V2

x86_64

Community

Debian 12

x86_64

Enterprise

Debian 12

x86_64

Community

Debian 11

x86_64

Enterprise

5.0.8+

Debian 11

x86_64

Community

5.0.8+

Debian 10

x86_64

Enterprise

Debian 10

x86_64

Community

Debian 9

x86_64

Enterprise

Debian 9

x86_64

Community

RHEL/Rocky/Alma/ Oracle Linux 9.0+ [2]

x86_64

Enterprise

6.0.4+

RHEL/Rocky/Alma/ Oracle Linux 9.0+ [2]

x86_64

Community

6.0.4+

RHEL/Rocky/Alma/ Oracle Linux 8.0+ [2]

x86_64

Enterprise

RHEL/Rocky/Alma/ Oracle Linux 8.0+ [2]

x86_64

Community

RHEL/ CentOS/ Oracle Linux 7.0+ [2]

x86_64

Enterprise

RHEL/ CentOS/ Oracle Linux 7.0+ [2]

x86_64

Community

RHEL/ CentOS/ Oracle Linux 6.2+ [2]

x86_64

Enterprise

RHEL/ CentOS/ Oracle Linux 6.2+ [2]

x86_64

Community

SLES 15

x86_64

Enterprise

SLES 15

x86_64

Community

SLES 12

x86_64

Enterprise

SLES 12

x86_64

Community

Ubuntu 24.04

x86_64

Enterprise

Ubuntu 24.04

x86_64

Community

Ubuntu 22.04

x86_64

Enterprise

6.0.4+

Ubuntu 22.04

x86_64

Community

6.0.4+

Ubuntu 20.04

x86_64

Enterprise

Ubuntu 20.04

x86_64

Community

Ubuntu 18.04

x86_64

Enterprise

Ubuntu 18.04

x86_64

Community

Ubuntu 16.04

x86_64

Enterprise

Ubuntu 16.04

x86_64

Community

Windows 11

x86_64

Enterprise

Windows 11

x86_64

Community

Windows Server 2022

x86_64

Enterprise

Windows Server 2022

x86_64

Community

Windows Server 2019

x86_64

Enterprise

Windows Server 2019

x86_64

Community

Windows 10 / Server 2016

x86_64

Enterprise

Windows 10 / Server 2016

x86_64

Community

macOS 14

x86_64

Enterprise

macOS 14

x86_64

Community

macOS 13

x86_64

Enterprise

macOS 13

x86_64

Community

macOS 12

x86_64

Enterprise

macOS 12

x86_64

Community

macOS 11

x86_64

Enterprise

macOS 11

x86_64

Community

macOS 10.15

x86_64

Enterprise

macOS 10.15

x86_64

Community

macOS 10.14

x86_64

Enterprise

macOS 10.14

x86_64

Community

macOS 10.13

x86_64

Enterprise

macOS 10.13

x86_64

Community

macOS 14

arm64

Enterprise

macOS 14

arm64

Community

macOS 13

arm64

Enterprise

macOS 13

arm64

Community

macOS 12

arm64

Enterprise

macOS 12

arm64

Community

macOS 11

arm64

Enterprise

macOS 11

arm64

Community

Amazon Linux 2023

arm64

Enterprise

Amazon Linux 2023

arm64

Community

Amazon Linux 2

arm64

Enterprise

4.4.4+

Amazon Linux 2

arm64

Community

4.4.4+

RHEL/CentOS/Rocky/Alma 9

arm64

Enterprise

RHEL/CentOS/Rocky/Alma 9

arm64

Community

RHEL/CentOS/Rocky/Alma 8

arm64

Enterprise

4.4.4+

RHEL/CentOS/Rocky/Alma 8

arm64

Community

4.4.4+

Ubuntu 24.04

arm64

Enterprise

Ubuntu 24.04

arm64

Community

Ubuntu 22.04

arm64

Enterprise

6.0.4+

Ubuntu 22.04

arm64

Community

6.0.4+

Ubuntu 20.04

arm64

Enterprise

Ubuntu 20.04

arm64

Community

Ubuntu 18.04

arm64

Enterprise

Ubuntu 18.04

arm64

Community

Ubuntu 16.04

arm64

Enterprise

RHEL/Rocky/Alma 9

ppc64le

Enterprise

RHEL/Rocky/Alma 8

ppc64le

Enterprise

RHEL/CentOS 7

ppc64le

Enterprise

6.0.7+

RHEL/Rocky/Alma 9

s390x

Enterprise

RHEL/Rocky/Alma 8

s390x

Enterprise

5.0.9+

RHEL/CentOS 7

s390x

Enterprise

RHEL/CentOS 7

s390x

Community

[2](1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 在Oracle Linux上, MongoDB仅支持 Red Hat Compatible Kernel。
PyMongo 版本
MongoDB 8.0
MongoDB 7.0
MongoDB 6.0
MongoDB 5.0
MongoDB 4.4
MongoDB 4.2
MongoDB 4.0
MongoDB 3.6

4.13

4.11 到 4.12

4.9 到 4.10

4.4 到 4.8

4.2 到 4.3

3.12 到 4.1

3.11

3.9 到 3.10

3.7 到 3.8

PyMongo 同时支持 CPython 和 PyPy。

当 Python 的一个版本被标记为生命周期结束 (EOL) 时,PyMongo 的下一个次要版本将删除对该版本的支持。 该驱动程序为 EOL Python 版本提供以下持续支持:

  • CPython :与 EOL CPython 版本兼容的最后一个 PyMongo 小版本获得了为期一年的重大错误修复。

  • PyPy :PyMongo 不支持超过 EOL 日期的 PyPy 版本。

以下兼容性表指定了与特定版本的 Python 一起使用的推荐版本 PyMongo。 第一列列出了驱动程序版本。

以下兼容性表显示了 PyMongo 与不同版本的 CPython 和 PyPy 的兼容性。

有关如何读取兼容性表的更多信息,请参阅 MongoDB兼容性表。

PyMongo 版本
CPython 3.13
CPython 3.12
CPython 3.11
CPython 3.10 [ 3 ]
CPython 3.9
CPython 3.8
CPython 3.7
CPython 3.6
CPython 3.5
CPython 3.4

4.11 到 4.13

4.9 到 4.10

4.8

4.5 到 4.7

4.3 到 4.4

4.2

4.1 [ 4 ]

4.0

3.13

3.12

3.11

3.10

3.7 到 3.9

PyMongo 版本
PyPy3.10
PyPy3.9
PyPy3.8
PyPy3.7
PyPy3.6
PyPy3.5

4.11 到 4.13

4.8 到 4.10

4.5 到 4.7

4.2 到 4.4

4.1 [ 4 ]

4.0

3.12

3.11

3.10

3.7 到 3.9

[3] Python 3.10及更高版本与MongoDB 4.0及更早版本的 TLS/SSL 不兼容。 有关详细信息,请参阅故障排除指南的 TLS部分。
[4]12 PyMongo 4.1 需要Python 3.6.2 或更高版本。

PyMongo版本 3.7 到 3.12 与Python 2.7 和 PyPy2.7 兼容。但是,在某些情况下, PyMongo应用程序在Python 2 环境中运行时的行为会有所不同。

以下部分描述了使用PyMongo时Python 2 和Python 3 之间的行为差异。

在所有版本的Python中, PyMongo将字节类的实例编码为具有子类型 0(二进制数据的默认子类型)的二进制数据。在Python 3 中, PyMongo将这些值解码为 bytes 类的实例。在Python2 中,驾驶员将它们解码为具有子类型 的 Binary0 类的实例。

以下代码示例展示了PyMongo如何解码 bytes 类的实例。选择 Python 2Python 3标签页以查看相应的代码。

from pymongo import MongoClient
client = MongoClient()
client.test.test.insert_one({'binary': b'this is a byte string'})
doc = client.test.test.find_one()
print(doc)
{u'_id': ObjectId('67afb78298f604a28f0247b4'), u'binary': Binary('this is a byte string', 0)}
from pymongo import MongoClient
client = MongoClient()
client.test.test.insert_one({'binary': b'this is a byte string'})
doc = client.test.test.find_one()
print(doc)
{'_id': ObjectId('67afb78298f604a28f0247b4'), 'binary': b'this is a byte string'}

在解码子类型为 0 的JSON二进制值时,驾驶员的行为方式相同。在Python 3 中,它将这些值解码为 bytes 类的实例。在Python 2 中,驾驶员将它们解码为具有子类型 0 的 Binary 类的实例。有关显示差异的代码示例,请参阅扩展JSON页面。

如果您在Python 2 中对 ObjectId 进行了 pickle,并想在Python 3 中对其进行 unpickle,则必须将 encoding='latin-1' 作为参数传递给 pickle.loads() 方法。

以下示例展示了如何使用Python 3 对在Python 2 中进行 pickle 的 ObjectId 进行 unpickle:

import pickle
pickle.loads(b'<ObjectId byte stream>', encoding='latin-1')

如果Python 3应用程序使用兼容的序列化协议来 pickle ObjectId,您可以使用Python 2 来取消 pickle。要在Python 3 中指定兼容协议,请为 pickle.dumps() 方法的 protocol 参数传递 0、1 或 2 的值。

以下示例在Python 3 中序列化 ObjectId,然后打印 ObjectId 和生成的 bytes实例:

import pickle
from bson.objectid import ObjectId
oid = ObjectId()
oid_bytes = pickle.dumps(oid, protocol=2)
print("ObjectId: {}".format(oid))
print("ObjectId bytes: {}".format(oid_bytes))
ObjectId: 67af9b1fae9260c0e97eb9eb
ObjectId bytes: b'\x80\x02cbson.objectid\nObjectId\nq\x00...

以下示例取消上一示例中 ObjectId 的封装,然后打印 bytesObjectId 实例:

import pickle
from bson.objectid import ObjectId
oid_bytes = b'\x80\x02cbson.objectid\nObjectId\nq\x00...'
oid = pickle.loads(oid_bytes)
print("ObjectId bytes: {}".format(oid_bytes))
print("ObjectId: {}".format(oid))
ObjectId bytes: b'\x80\x02cbson.objectid\nObjectId\nq\x00)...
ObjectId: 67af9b1fae9260c0e97eb9eb

下表显示了Motor和PyMongo的等效版本。

Motor版本
PyMongo 版本

3.7

4.10

3.6

4.9

3.3

4.4

3.1

4.2

3.0

4.0

后退

版本说明

在此页面上