中文 | English
Use Agora RTC SDK with Python!
NEWS: AudioFrameObserver
has been supported since v3.1.2.10.
Either can you install this module from PyPI using pip3
or compile the SDK yourself using the code in this repository.
Only support for 64-bit OS. For 32-bit OS, please refer to Method 2.
pip3 install agora-python-sdk
Clone the repository.
git clone https://github.com/AgoraIO-Community/Agora-Python-SDK.git
Download the required SDK.
AograRtcEngineKit.framework
from libs
folder into the repository root folder.agora_rtc_sdk.dll
and agora_rtc_sdk.lib
files from libs/x86_64
(64-bit) or libs/x86
(32-bit) into repository root folder.Compile SDK.
Open Terminal and use cd
to go to the repository root folder. Then compile using:
python3 setup.py build_ext --inplace
(Optional) Add agorartc
module to site-packages
folder.
If you would like to use our SDK globally, you need to copy the related files and folder to your python site-packages folder. You can find the path using:
python3 -c 'import site; print(site.getsitepackages())'
Copy _agorartc.cpython-38-darwin.so
, agorartc.py
and AgoraRtcKit.framework
or agora_rtc_sdk.dll
and agora_rtc_sdk.lib
to your site-packages
path.
macOS (Terminal)
cp _agorartc.cpython-38-darwin.so [your-site-packages-folder-path]
cp agorartc.py [your-site-packages-folder-path]
cp -r AgoraRtcKit.framework [your-site-packages-folder-path]
Windows (PowerShell)
cp _agorartc.cpython-38-darwin.so [your-site-packages-folder-path]
cp agorartc.py [your-site-packages-folder-path]
cp agora_rtc_sdk.dll [your-site-packages-folder-path]
cp agora_rtc_sdk.lib [your-site-packages-folder-path]
Visit Agora-Python-QuickStart to obtain some existed GUI demos.
You can also write a simple demo yourself by the following instructins.
Open a Python3 console in Terminal (macOS) or PowerShell (Windows).
python3
Write a simple demo in Python console.
>>> import agorartc
>>> rtc = agorartc.createRtcEngineBridge()
>>> eventHandler = agorartc.RtcEngineEventHandlerBase()
>>> rtc.initEventHandler(eventHandler)
0 (Success)
>>> rtc.initialize("your-appID", None, agorartc.AREA_CODE_GLOB & 0xFFFFFFFF) # If you do not have an App ID, see Appendix (https://github.com/AgoraIO-Community/Agora-Python-SDK#appendix).
0 (Success)
>>> rtc.enableVideo()
0 (Success)
>>> rtc.joinChannel("", "channel-name", "", 0)
0 (Success)
>>> rtc.leaveChannel() # Leave channel
0 (Success)
>>> rtc.release()
For more information about our API, please refer to Agora C++ API.
The API reference for Python is on proceeding while C++ API is similar.
To use our SDK, you must obtain an app ID: