pymongo 4.15.3


pip install pymongo

  Latest version

Released: Oct 07, 2025


Meta
Author: The MongoDB Python Team
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License

Operating System
  • MacOS :: MacOS X
  • Microsoft :: Windows
  • POSIX

Programming Language
  • Python :: 3
  • Python :: 3 :: Only
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

Topic
  • Database

Typing
  • Typed

PyMongo

PyPI Version Python Versions Monthly Downloads API Documentation Status

About

The PyMongo distribution contains tools for interacting with MongoDB database from Python. The bson package is an implementation of the BSON format for Python. The pymongo package is a native Python driver for MongoDB, offering both synchronous and asynchronous APIs. The gridfs package is a gridfs implementation on top of pymongo.

PyMongo supports MongoDB 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. PyMongo follows semantic versioning for its releases.

Documentation

Documentation is available at mongodb.com.

API documentation and the full changelog for each release is available at readthedocs.io.

Support / Feedback

For issues with, questions about, or feedback for PyMongo, please look into our support channels. Please do not email any of the PyMongo developers directly with issues or questions - you're more likely to get an answer on StackOverflow (using a "mongodb" tag).

Bugs / Feature Requests

Think you've found a bug? Want to see a new feature in PyMongo? Please open a case in our issue management tool, JIRA:

Bug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are public.

How To Ask For Help

Please include all of the following information when opening an issue:

  • Detailed steps to reproduce the problem, including full traceback, if possible.

  • The exact python version used, with patch level:

python -c "import sys; print(sys.version)"
  • The exact version of PyMongo used, with patch level:
python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"
  • The operating system and version (e.g. Windows 7, OSX 10.8, ...)

  • Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)

Security Vulnerabilities

If you've identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Installation

PyMongo can be installed with pip:

python -m pip install pymongo

You can also download the project source and do:

pip install .

Do not install the "bson" package from pypi. PyMongo comes with its own bson package; running "pip install bson" installs a third-party package that is incompatible with PyMongo.

Dependencies

PyMongo supports CPython 3.9+ and PyPy3.10+.

Required dependencies:

Support for mongodb+srv:// URIs requires dnspython

Optional dependencies:

GSSAPI authentication requires pykerberos on Unix or WinKerberos on Windows. The correct dependency can be installed automatically along with PyMongo:

python -m pip install "pymongo[gssapi]"

MONGODB-AWS authentication requires pymongo-auth-aws:

python -m pip install "pymongo[aws]"

OCSP (Online Certificate Status Protocol) requires PyOpenSSL, requests, service_identity and may require certifi:

python -m pip install "pymongo[ocsp]"

Wire protocol compression with snappy requires python-snappy:

python -m pip install "pymongo[snappy]"

Wire protocol compression with zstandard requires zstandard:

python -m pip install "pymongo[zstd]"

Client-Side Field Level Encryption requires pymongocrypt and pymongo-auth-aws:

python -m pip install "pymongo[encryption]"

You can install all dependencies automatically with the following command:

python -m pip install "pymongo[gssapi,aws,ocsp,snappy,zstd,encryption]"

Examples

Here's a basic example (for more see the examples section of the docs):

>>> import pymongo
>>> client = pymongo.MongoClient("localhost", 27017)
>>> db = client.test
>>> db.name
'test'
>>> db.my_collection
Collection(Database(MongoClient('localhost', 27017), 'test'), 'my_collection')
>>> db.my_collection.insert_one({"x": 10}).inserted_id
ObjectId('4aba15ebe23f6b53b0000000')
>>> db.my_collection.insert_one({"x": 8}).inserted_id
ObjectId('4aba160ee23f6b543e000000')
>>> db.my_collection.insert_one({"x": 11}).inserted_id
ObjectId('4aba160ee23f6b543e000002')
>>> db.my_collection.find_one()
{'x': 10, '_id': ObjectId('4aba15ebe23f6b53b0000000')}
>>> for item in db.my_collection.find():
...     print(item["x"])
...
10
8
11
>>> db.my_collection.create_index("x")
'x_1'
>>> for item in db.my_collection.find().sort("x", pymongo.ASCENDING):
...     print(item["x"])
...
8
10
11
>>> [item["x"] for item in db.my_collection.find().limit(2).skip(1)]
[8, 11]

Learning Resources

Testing

The easiest way to run the tests is to run the following from the repository root.

pip install -e ".[test]"
pytest

For more advanced testing scenarios, see the contributing guide.

4.15.3 Oct 07, 2025
4.15.2 Oct 01, 2025
4.15.1 Sep 16, 2025
4.15.0 Sep 10, 2025
4.14.1 Aug 19, 2025
4.14.0 Aug 06, 2025
4.13.2 Jun 16, 2025
4.13.1 Jun 11, 2025
4.13.0 May 14, 2025
4.13.0.dev0 May 14, 2025
4.12.1 Apr 29, 2025
4.12.0 Apr 08, 2025
4.11.3 Mar 18, 2025
4.11.2 Mar 03, 2025
4.11.1 Feb 10, 2025
4.11 Jan 28, 2025
4.10.1 Oct 01, 2024
4.10.0 Oct 01, 2024
4.9.2 Oct 02, 2024
4.9.1 Sep 18, 2024
4.9 Sep 18, 2024
4.8.0 Jun 26, 2024
4.8.0b0 Jun 25, 2024
4.7.3 Jun 04, 2024
4.7.2 May 07, 2024
4.7.1 Apr 30, 2024
4.7.0 Apr 24, 2024
4.6.3 Mar 28, 2024
4.6.2 Feb 21, 2024
4.6.1 Nov 29, 2023
4.6.0 Nov 01, 2023
4.5.0 Aug 22, 2023
4.4.1 Jul 13, 2023
4.4.0 Jun 21, 2023
4.4.0b0 Jan 25, 2023
4.3.3 Nov 17, 2022
4.3.2 Oct 18, 2022
4.2.0 Jul 20, 2022
4.1.1 Apr 13, 2022
4.1.0 Apr 04, 2022
4.0.2 Mar 03, 2022
4.0.1 Dec 07, 2021
4.0 Nov 29, 2021
3.13.0 Nov 01, 2022
3.12.3 Dec 07, 2021
3.12.2 Nov 29, 2021
3.12.1 Oct 19, 2021
3.12.0 Jul 13, 2021
3.11.4 May 04, 2021
3.11.3 Feb 03, 2021
3.11.2 Dec 02, 2020
3.11.1 Nov 17, 2020
3.11.0 Jul 30, 2020
3.10.1 Jan 08, 2020
3.10.0 Dec 10, 2019
3.9.0 Aug 14, 2019
3.8.0 Apr 22, 2019
3.7.2 Oct 10, 2018
3.7.1 Jul 16, 2018
3.7.0 Jun 26, 2018
3.6.1 Mar 01, 2018
3.6.0 Dec 05, 2017
3.5.1 Aug 23, 2017
3.5.0 Aug 08, 2017
3.4.0 Nov 29, 2016
3.3.1 Oct 27, 2016
3.3.0 Jul 12, 2016
3.2.2 Mar 15, 2016
3.2.1 Feb 02, 2016
3.2 Dec 08, 2015
3.1.1 Nov 18, 2015
3.1 Nov 02, 2015
3.0.3 Jul 01, 2015
3.0.2 May 12, 2015
3.0.1 Apr 21, 2015
3.0 Apr 07, 2015
2.9.5 Jun 30, 2017
2.9.4 Sep 30, 2016
2.9.3 Mar 15, 2016
2.9.2 Feb 01, 2016
2.9.1 Nov 17, 2015
2.9 Sep 30, 2015
2.8.1 May 11, 2015
2.8 Jan 28, 2015
2.7.2 Jul 29, 2014
2.7.1 May 23, 2014
2.7 Apr 03, 2014
2.6.3 Oct 11, 2013
2.6.2 Sep 06, 2013
2.6.1 Sep 04, 2013
2.6 Aug 19, 2013
2.5.2 Jun 01, 2013
2.5.1 May 13, 2013
2.5 Mar 22, 2013
2.4.2 Jan 24, 2013
2.4.1 Dec 06, 2012
2.4 Nov 27, 2012
2.3 Aug 29, 2012
2.2.1 Jul 06, 2012
2.2 Apr 30, 2012
2.1.1 Jan 05, 2012
2.1 Dec 07, 2011
2.0.1 Aug 16, 2011
2.0 Aug 06, 2011
1.11 May 06, 2011
1.10.1 Apr 07, 2011
1.10 Mar 30, 2011
1.9 Sep 28, 2010
1.8.1 Aug 13, 2010
1.8 Aug 05, 2010
1.7 Jun 17, 2010
1.6 Apr 14, 2010
1.5.2 Mar 31, 2010
1.5.1 Mar 17, 2010
1.5 Mar 10, 2010
1.4 Jan 27, 2010
1.3 Dec 16, 2009
1.2.1 Dec 10, 2009
1.2 Dec 09, 2009
1.1.2 Nov 23, 2009
1.1.1 Nov 14, 2009
1.1 Oct 21, 2009
1.0 Sep 30, 2009
0.16 Sep 16, 2009
0.15.2 Sep 09, 2009
0.15.1 Sep 03, 2009
0.15 Aug 26, 2009
0.14.2 Aug 24, 2009
0.14.1 Aug 21, 2009
0.14 Aug 19, 2009
0.13 Jul 29, 2009
0.12 Jul 08, 2009
0.11.3 Jun 18, 2009
0.11.2 Jun 08, 2009
0.11.1 Jun 04, 2009
0.11 Jun 03, 2009
0.10.3 May 27, 2009
0.10.2 May 22, 2009
0.10.1 May 18, 2009
0.10 May 14, 2009
0.9.7 May 13, 2009
0.9.6 May 08, 2009
0.9.5 Apr 15, 2009
0.9.4 Apr 15, 2009
0.9.3 Apr 03, 2009
0.9.2 Mar 26, 2009
0.9.1 Mar 18, 2009
0.9 Mar 17, 2009
0.8.1 Feb 27, 2009
0.8 Feb 20, 2009
0.7.2 Feb 20, 2009
0.7.1 Feb 20, 2009
0.7 Feb 17, 2009
0.6 Feb 11, 2009
0.5.3rc0 Feb 09, 2009
0.5.2rc0 Feb 06, 2009
0.5.1rc0 Feb 06, 2009
0.5rc0 Feb 05, 2009
0.4rc0 Feb 05, 2009
0.3.1rc0 Feb 03, 2009
0.3rc0 Jan 30, 2009
0.2rc0 Jan 27, 2009
0.1.2rc0 Jan 23, 2009
0.1.1rc0 Jan 23, 2009
0.1rc0 Jan 22, 2009
3.2.win32 Dec 08, 2015
3.2.win Dec 08, 2015
3.2.2.win32 Mar 15, 2016
3.2.2.win Mar 15, 2016
3.2.1.win32 Feb 02, 2016
3.2.1.win Feb 02, 2016
3.1.win32 Nov 02, 2015
3.1.win Nov 02, 2015
3.1.1.win32 Nov 18, 2015
3.1.1.win Nov 18, 2015
3.0.win32 Apr 07, 2015
3.0.win Apr 07, 2015
3.0.3.win32 Jul 01, 2015
3.0.3.win Jul 01, 2015
3.0.2.win32 May 12, 2015
3.0.2.win May 12, 2015
3.0.1.win32 Apr 21, 2015
3.0.1.win Apr 21, 2015
2.9.win32 Sep 30, 2015
2.9.win Oct 01, 2015
2.9.4.win32 Sep 30, 2016
2.9.4.win Sep 30, 2016
2.9.3.win32 Mar 15, 2016
2.9.3.win Mar 15, 2016
2.9.2.win32 Feb 01, 2016
2.9.2.win Feb 02, 2016
2.9.1.win32 Nov 17, 2015
2.9.1.win Nov 18, 2015
2.8.win32 Jan 28, 2015
2.8.win Jan 28, 2015
2.8.1.win32 May 11, 2015
2.8.1.win May 11, 2015
2.7.win32 Apr 03, 2014
2.7.win Apr 03, 2014
2.7.2.win32 Jul 29, 2014
2.7.2.win Jul 29, 2014
2.7.1.win32 May 23, 2014
2.7.1.win May 23, 2014
2.6.win32 Aug 19, 2013
2.6.win Aug 19, 2013
2.6.3.win32 Oct 11, 2013
2.6.3.win Oct 11, 2013
2.6.2.win32 Sep 06, 2013
2.6.2.win Sep 06, 2013
2.6.1.win32 Sep 04, 2013
2.6.1.win Sep 04, 2013
2.5.win32 Mar 22, 2013
2.5.win Mar 22, 2013
2.5.2.win32 Jun 01, 2013
2.5.2.win Jun 01, 2013
2.5.1.win32 May 13, 2013
2.5.1.win May 13, 2013
2.4.win32 Nov 27, 2012
2.4.win Nov 27, 2012
2.4.2.win32 Jan 24, 2013
2.4.2.win Jan 24, 2013
2.4.1.win32 Dec 06, 2012
2.4.1.win Dec 06, 2012
2.3.win32 Aug 29, 2012
2.3.win Aug 29, 2012
2.2.win32 Apr 30, 2012
2.2.win Apr 30, 2012
2.2.1.win32 Jul 06, 2012
2.2.1.win Jul 06, 2012
2.1.win32 Dec 07, 2011
2.1.win Dec 07, 2011
2.1.1.win32 Jan 05, 2012
2.1.1.win Jan 05, 2012
2.0.win32 Aug 06, 2011
2.0.win Aug 06, 2011
2.0.1.win32 Aug 16, 2011
2.0.1.win Aug 16, 2011
1.9.win32 Sep 29, 2010
1.8.win32 Aug 05, 2010
1.8.1.win32 Aug 13, 2010
1.7.win32 Jun 17, 2010
1.11.win32 May 06, 2011
1.10.win32 Mar 30, 2011
1.10.1.win32 Apr 07, 2011

Wheel compatibility matrix

Platform CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.14
macosx_10_13_x86_64
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux1_i686
manylinux2014_aarch64
manylinux2014_ppc64le
manylinux2014_s390x
manylinux2014_x86_64
manylinux_2_17_aarch64
manylinux_2_17_ppc64le
manylinux_2_17_s390x
manylinux_2_17_x86_64
manylinux_2_28_aarch64
manylinux_2_28_i686
manylinux_2_28_ppc64le
manylinux_2_28_s390x
manylinux_2_28_x86_64
manylinux_2_5_i686
win32
win_amd64
win_arm64

Files in release

pymongo-4.15.3-cp310-cp310-macosx_10_9_x86_64.whl (792.3KiB)
pymongo-4.15.3-cp310-cp310-macosx_11_0_arm64.whl (792.6KiB)
pymongo-4.15.3-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (1.1MiB)
pymongo-4.15.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.1MiB)
pymongo-4.15.3-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (1.2MiB)
pymongo-4.15.3-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (1.2MiB)
pymongo-4.15.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.1MiB)
pymongo-4.15.3-cp310-cp310-win32.whl (779.6KiB)
pymongo-4.15.3-cp310-cp310-win_amd64.whl (789.2KiB)
pymongo-4.15.3-cp310-cp310-win_arm64.whl (782.2KiB)
pymongo-4.15.3-cp311-cp311-macosx_10_9_x86_64.whl (845.6KiB)
pymongo-4.15.3-cp311-cp311-macosx_11_0_arm64.whl (845.9KiB)
pymongo-4.15.3-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (1.4MiB)
pymongo-4.15.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.4MiB)
pymongo-4.15.3-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (1.4MiB)
pymongo-4.15.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (1.4MiB)
pymongo-4.15.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.4MiB)
pymongo-4.15.3-cp311-cp311-win32.whl (824.7KiB)
pymongo-4.15.3-cp311-cp311-win_amd64.whl (839.1KiB)
pymongo-4.15.3-cp311-cp311-win_arm64.whl (828.5KiB)
pymongo-4.15.3-cp312-cp312-macosx_10_13_x86_64.whl (899.4KiB)
pymongo-4.15.3-cp312-cp312-macosx_11_0_arm64.whl (899.1KiB)
pymongo-4.15.3-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (1.6MiB)
pymongo-4.15.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.6MiB)
pymongo-4.15.3-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (1.7MiB)
pymongo-4.15.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (1.7MiB)
pymongo-4.15.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.6MiB)
pymongo-4.15.3-cp312-cp312-win32.whl (870.4KiB)
pymongo-4.15.3-cp312-cp312-win_amd64.whl (889.6KiB)
pymongo-4.15.3-cp312-cp312-win_arm64.whl (875.3KiB)
pymongo-4.15.3-cp313-cp313-macosx_10_13_x86_64.whl (952.5KiB)
pymongo-4.15.3-cp313-cp313-macosx_11_0_arm64.whl (952.3KiB)
pymongo-4.15.3-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (1.9MiB)
pymongo-4.15.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (1.9MiB)
pymongo-4.15.3-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (2.0MiB)
pymongo-4.15.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (2.0MiB)
pymongo-4.15.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.9MiB)
pymongo-4.15.3-cp313-cp313-win32.whl (916.1KiB)
pymongo-4.15.3-cp313-cp313-win_amd64.whl (940.0KiB)
pymongo-4.15.3-cp313-cp313-win_arm64.whl (922.2KiB)
pymongo-4.15.3-cp314-cp314-macosx_10_13_x86_64.whl (1005.7KiB)
pymongo-4.15.3-cp314-cp314-macosx_11_0_arm64.whl (1005.5KiB)
pymongo-4.15.3-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (2.1MiB)
pymongo-4.15.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (2.2MiB)
pymongo-4.15.3-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (2.3MiB)
pymongo-4.15.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (2.2MiB)
pymongo-4.15.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.1MiB)
pymongo-4.15.3-cp314-cp314-win32.whl (969.6KiB)
pymongo-4.15.3-cp314-cp314-win_amd64.whl (997.3KiB)
pymongo-4.15.3-cp314-cp314-win_arm64.whl (977.2KiB)
pymongo-4.15.3-cp314-cp314t-macosx_10_13_x86_64.whl (1.0MiB)
pymongo-4.15.3-cp314-cp314t-macosx_11_0_arm64.whl (1.0MiB)
pymongo-4.15.3-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (2.4MiB)
pymongo-4.15.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (2.5MiB)
pymongo-4.15.3-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (2.6MiB)
pymongo-4.15.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (2.6MiB)
pymongo-4.15.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (2.5MiB)
pymongo-4.15.3-cp314-cp314t-win32.whl (1019.5KiB)
pymongo-4.15.3-cp314-cp314t-win_amd64.whl (1.0MiB)
pymongo-4.15.3-cp314-cp314t-win_arm64.whl (1.0MiB)
pymongo-4.15.3-cp39-cp39-macosx_10_9_x86_64.whl (739.0KiB)
pymongo-4.15.3-cp39-cp39-macosx_11_0_arm64.whl (739.4KiB)
pymongo-4.15.3-cp39-cp39-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (921.5KiB)
pymongo-4.15.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (930.5KiB)
pymongo-4.15.3-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (949.2KiB)
pymongo-4.15.3-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (944.3KiB)
pymongo-4.15.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (928.4KiB)
pymongo-4.15.3-cp39-cp39-win32.whl (734.5KiB)
pymongo-4.15.3-cp39-cp39-win_amd64.whl (739.4KiB)
pymongo-4.15.3-cp39-cp39-win_arm64.whl (735.8KiB)
pymongo-4.15.3.tar.gz (2.4MiB)
Extras:
Dependencies:
dnspython (<3.0.0,>=1.16.0)