---
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.

---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';

import UnderscoreMainExample from '!!raw-loader!./code/actor_structure/main.py';
import MainExample from '!!raw-loader!./code/actor_structure/__main__.py';

## Step 1: Create Actors

To create and run Actors in Apify Console, refer to the [Console documentation](https://docs.apify.com/platform/console).

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](https://apify.com/templates?category=python).

For example, to create an Actor from the Python SDK template, you can use the [`apify create` command](https://docs.apify.com/cli/docs/reference#apify-create-actorname).

```bash
apify create my-first-actor --template python-start
```

This will create a new folder called `my-first-actor`, download and extract the "Getting started with Python" Actor template there, create a virtual environment in `my-first-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
cd my-first-actor
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

All Python Actor templates follow the same 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. This folder contains 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](../concepts/logging) and executing the Actor's main function via [`asyncio.run`](https://docs.python.org/3/library/asyncio-runner.html#asyncio.run).

<Tabs>
    <TabItem value="main.py" label="main.py" default>
        <CodeBlock className="language-python">
            {MainExample}
        </CodeBlock>
    </TabItem>
    <TabItem value="__main__.py" label="__main.py__">
        <CodeBlock className="language-python">
            {UnderscoreMainExample}
        </CodeBlock>
    </TabItem>
</Tabs>

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. We recommend keeping the entrypoint for the Actor in the `src/__main__.py` file.

## Step 4: Add dependencies {#adding-dependencies}

Adding dependencies into the Actor is simple.

First, add them in the [`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file in the Actor source folder.

Then activate the virtual environment in `.venv`:

<Tabs groupId="operating-systems">
    <TabItem value="unix" label="Linux / macOS" default>
        <CodeBlock language="bash">{
`source .venv/bin/activate`
        }</CodeBlock>
    </TabItem>
    <TabItem value="win" label="Windows">
        <CodeBlock language="powershell">{
`.venv\\Scripts\\activate`
        }</CodeBlock>
    </TabItem>
</Tabs>

Then install the dependencies:

```bash
python -m pip install -r requirements.txt
```

## Next steps

### Concepts

For a deeper understanding of the Apify SDK's features, refer to the Concepts section in the sidebar:

- [Actor lifecycle](../concepts/actor-lifecycle)
- [Actor input](../concepts/actor-input)
- [Working with storages](../concepts/storages)
- [Actor events & state persistence](../concepts/actor-events)
- [Proxy management](../concepts/proxy-management)
- [Interacting with other Actors](../concepts/interacting-with-other-actors)
- [Creating webhooks](../concepts/webhooks)
- [Accessing Apify API](../concepts/access-apify-api)
- [Logging](../concepts/logging)
- [Actor configuration](../concepts/actor-configuration)
- [Pay-per-event monetization](../concepts/pay-per-event)

### Guides

Integrate the Apify SDK with popular web scraping libraries by following these guides:

- [BeautifulSoup with HTTPX](../guides/beautifulsoup-httpx)
- [Crawlee](../guides/crawlee)
- [Playwright](../guides/playwright)
- [Selenium](../guides/selenium)
- [Scrapy](../guides/scrapy)
- [Running webserver](../guides/running-webserver)
