> This page location: /docs.md > /docs/drivers.md > /docs/languages/python.md

> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Motor (Async Driver)

As of May 14, 2025, Motor is deprecated in favor of the GA release of the PyMongo Async API in the PyMongo library. We will not add new features to Motor, and we will provide only bug fixes until it reaches end of life on May 14, 2026. After that, we will fix only critical bugs until final support ends on May 14, 2027. We strongly recommend migrating to the PyMongo Async API while Motor is still supported.

For more information about migrating, see the [Migrate to PyMongo Async](https://www.mongodb.com/docs/languages/python/pymongo-driver/current/reference/migration/) guide in the PyMongo documentation.

## Introduction

Welcome to the documentation site for Motor, the official MongoDB driver for asynchronous Python applications. Download it using [pip](https://pypi.python.org/pypi/pip) or set up a runnable project by following our tutorials.

**Tip:**

If you do not need to access MongoDB in a non-blocking manner or from co-routines, we recommend that you use the [PyMongo](https://www.mongodb.com/docs/languages/python/pymongo-driver/current/) driver instead.

- [Tutorial on using Motor with Tornado](http://motor.readthedocs.org/en/stable/tutorial-tornado.html)

- [Tutorial on using Motor with asyncio](https://motor.readthedocs.io/en/stable/tutorial-asyncio.html)

- [Motor Documentation](http://motor.readthedocs.org/)

- [Changelog](http://motor.readthedocs.org/en/stable/changelog.html)

- [Source Code](https://github.com/mongodb/motor/)

Follow the links below to read blog posts that describe specific use cases for the Motor driver:

- [Porting From PyMongo To Motor](http://emptysqua.re/blog/porting-from-pymongo-to-motor/)

- [Refactoring Tornado Coroutines](http://emptysqua.re/blog/refactoring-tornado-coroutines/)

- [All Motor articles on A. Jesse Jiryu Davis's blog](http://emptysqua.re/blog/category/motor/)

## Installation

You must install the Motor driver module to make it available to your Python application. We recommend using [pip](http://pypi.python.org/pypi/pip) to install Motor.

The following command demonstrates how you can install the latest version of the module using the command line:

```sh
$ python -m pip install motor
```

For more information on requirements and other methods of installation, see the [Motor Installation](https://motor.readthedocs.io/en/stable/installation.html) documentation.

## Connect to MongoDB Atlas

You can use the following connection snippet to test your connection to your MongoDB deployment on Atlas using the `asyncio` asynchronous framework:

```python
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo.server_api import ServerApi

async def ping_server():
  # Replace the placeholder with your Atlas connection string
  uri = "<connection string>"

  # Set the Stable API version when creating a new client
  client = AsyncIOMotorClient(uri, server_api=ServerApi('1'))

  # Send a ping to confirm a successful connection
  try:
      await client.admin.command('ping')
      print("Pinged your deployment. You successfully connected to MongoDB!")
  except Exception as e:
      print(e)
      
asyncio.run(ping_server())
```

This connection snippet uses the Stable API feature, which you can enable when using the Motor driver v2.5 and later to connect to MongoDB Server v5.0 and later. When you use this feature, you can update your driver or server without worrying about backward compatibility issues with any commands covered by the Stable API.

To learn more about the Stable API feature, see [Stable API](https://www.mongodb.com/docs/manual/reference/stable-api/) in the Server manual.

**Note:**

Starting from February 2022, the **Versioned API** is known as the **Stable API**. All concepts and features remain the same with this naming change.

## Connect to MongoDB Atlas Without the Stable API

If you are using a version of MongoDB or the driver that doesn't support the Stable API feature, you can use the following code snippet to test your connection to your MongoDB deployment on Atlas:

```python
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient

async def ping_server():
  # Replace the placeholder with your Atlas connection string
  uri = "<connection string>"

  # Create a new client and connect to the server
  client = AsyncIOMotorClient(uri)

  # Send a ping to confirm a successful connection
  try:
      await client.admin.command('ping')
      print("Pinged your deployment. You successfully connected to MongoDB!")
  except Exception as e:
      print(e)
      
asyncio.run(ping_server())
```

If you are using the `tornado` asynchronous library, you can use the following code to connect to your MongoDB deployment:

```python
import tornado
import motor

async def ping_server():
    # Replace the placeholder with your Atlas connection string
    uri = "<connection string>"

    # Set a 5-second connection timeout when creating a new client
    client = motor.motor_tornado.MotorClient(uri, serverSelectionTimeoutMS=5000)

    # Send a ping to confirm a successful connection
    try:
      await client.admin.command('ping')
      print("Pinged your deployment. You successfully connected to MongoDB!")
    except Exception as e:
      print(e)

tornado.ioloop.IOLoop.current().run_sync(ping_server)
```

## Connect to a MongoDB Server on Your Local Machine

If you need to run a MongoDB server on your local machine for development purposes instead of using an Atlas cluster, you need to complete the following:

1. Download the [Community](https://www.mongodb.com/try/download/community) or [Enterprise](https://www.mongodb.com/try/download/enterprise) version of MongoDB Server.

2. [Install and configure](https://www.mongodb.com/docs/manual/installation/) MongoDB Server.

3. Start the server.

**Important:**

Always secure your MongoDB server from malicious attacks. See our [Security Checklist](https://www.mongodb.com/docs/manual/administration/security-checklist/) for a list of security recommendations.

After you successfully start your MongoDB server, specify your connection string in your driver connection code.

If your MongoDB Server is running locally, you can use the connection string `"mongodb://localhost:<port>"` where `<port>` is the port number you configured your server to listen for incoming connections.

If you need to specify a different hostname or IP address, see our Server Manual entry on [Connection Strings.](https://www.mongodb.com/docs/manual/reference/connection-string/)

To test whether you can connect to your server, replace the connection string in the [Connect to MongoDB Atlas](https://www.mongodb.com/docs/drivers/motor.md#std-label-connect-atlas-motor-driver) code example and run it.

## Compatibility

For information about Motor's compatibility with MongoDB Server and Python, see the [Compatibility](https://www.mongodb.com/docs/drivers/compatibility/?driver-language=python\&python-driver-framework=motor) page.

### How to get help

- Ask for help in the MongoDB [Stack Overflow page](https://stackoverflow.com/questions/tagged/mongodb) or in the MongoDB [Reddit community.](https://www.reddit.com/r/MongoDB_Official/)

- Visit our [Support Channels.](https://www.mongodb.com/docs/manual/support/)

- See [JIRA](https://jira.mongodb.org/projects/MOTOR/summary) to raise issues or request features.
