You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: 'The official library for creating Apify Actors in Python, providing tools for web scraping, automation, and data storage integration.'
6
+
---
7
+
8
+
The Apify SDK for Python is the official library for creating [Apify Actors](https://docs.apify.com/platform/actors) in Python.
9
+
10
+
It provides tools and classes for web scraping and automation, allowing you to manage Actor lifecycles, handle data storage, work with proxies, and integrate with popular Python libraries.
11
+
12
+
## Example
13
+
14
+
Here's a simple example of an Actor that scrapes a web page and stores the result:
description: 'Learn how to install the Apify SDK for Python using pip and manage dependencies for your Actor projects.'
5
+
---
6
+
7
+
importTabsfrom'@theme/Tabs';
8
+
importTabItemfrom'@theme/TabItem';
9
+
importCodeBlockfrom'@theme/CodeBlock';
10
+
11
+
## Requirements
12
+
13
+
The Apify SDK requires Python version 3.10 or above to run Python Actors locally.
14
+
15
+
## Installation
16
+
17
+
The Apify Python SDK is available as [`apify`](https://pypi.org/project/apify/) package on PyPi. To install it, run:
18
+
19
+
```bash
20
+
pip install apify
21
+
```
22
+
23
+
When you create an Actor using the Apify CLI, the Apify SDK for Python is installed for you automatically.
24
+
25
+
If you are not developing Apify Actors and you just need to access the Apify API from Python,
26
+
consider using the [Apify API client for Python](/api/client/python) directly.
27
+
28
+
## Adding dependencies
29
+
30
+
First, add the dependencies in the [`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file in the Actor source folder.
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.
To run the Actor, you can use the [`apify run` command](/cli/docs/reference#apify-run):
63
34
@@ -74,7 +45,7 @@ This command:
74
45
75
46
The Actor input, for example, will be in `storage/key_value_stores/default/INPUT.json`.
76
47
77
-
## Actor structure
48
+
## Step 3: Understanding Actor structure
78
49
79
50
All Python Actor templates follow the same structure.
80
51
@@ -122,31 +93,6 @@ asyncio.run(main())`
122
93
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.
123
94
We recommend keeping the entrypoint for the Actor in the `src/__main__.py` file.
124
95
125
-
## Adding dependencies
126
-
127
-
First, add the dependencies in the [`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) file in the Actor source folder.
0 commit comments