---
id: quick-start
title: Quick start
sidebar_label: Quick start
description: 'Get started with the Apify SDK for Python by creating your first Actor and learning the basics.'
---

Learn how to create and run Actors using the Apify SDK for Python.

---

## Step 1: Create Actors

To create a new Apify Actor on your computer, you can use the [Apify CLI](https://docs.apify.com/cli) and select one of the Python Actor templates.

```bash
apify create my-python-actor --template python-sdk
cd my-python-actor
```

This will create a new folder called `my-python-actor`, download and extract the Python SDK Actor template there, create a virtual environment in `my-python-actor/.venv`, and install the Actor dependencies in it.

## Step 2: Run Actors

To run the Actor, you can use the [`apify run` command](https://docs.apify.com/cli/docs/reference#apify-run):

```bash
apify run
```

This command:

- Activates the virtual environment in `.venv` (if no other virtual environment is activated yet)
- Starts the Actor with the appropriate environment variables for local running
- Configures it to use local storages from the `storage` folder

The Actor input, for example, will be in `storage/key_value_stores/default/INPUT.json`.

## Step 3: Understand Actor structure

The `.actor` directory contains the [Actor configuration](https://docs.apify.com/platform/actors/development/actor-config), such as the Actor's definition and input schema, and the Dockerfile necessary to run the Actor on the Apify platform.

The Actor's runtime dependencies are specified in the `requirements.txt` file, which follows the [standard requirements file format](https://pip.pypa.io/en/stable/reference/requirements-file-format/).

The Actor's source code is in the `src` folder with two important files:

- `main.py` - which contains the main function of the Actor
- `__main__.py` - which is the entrypoint of the Actor package, setting up the Actor logger and executing the Actor's main function via [`asyncio.run()`](https://docs.python.org/3/library/asyncio-runner.html#asyncio.run).

```python title="src/main.py"
from apify import Actor

async def main():
    async with Actor:
        print('Actor input:', await Actor.get_input())
        await Actor.set_value('OUTPUT', 'Hello, world!')
```

```python title="src/__main__.py"
import asyncio
import logging

from apify.log import ActorLogFormatter

from .main import main

handler = logging.StreamHandler()
handler.setFormatter(ActorLogFormatter())

apify_logger = logging.getLogger('apify')
apify_logger.setLevel(logging.DEBUG)
apify_logger.addHandler(handler)

asyncio.run(main())
```

If you want to modify the Actor structure, you need to make sure that your Actor is executable as a module, via `python -m src`, as that is the command started by `apify run` in the Apify CLI.

## Next steps

To learn more about the features of the Apify SDK and how to use them, check out the Concepts section, especially:

- [Actor lifecycle](../concepts/actor-lifecycle)
- [Working with storages](../concepts/storages)
- [Working with proxies](../concepts/proxy-management)
- [Managing Actor events](../concepts/actor-events)
- [Direct access to the Apify API](../concepts/access-apify-api)
