中文 | English
Use Agora RTC SDK with Python!
NEWS: AudioFrameObserver
has been supported since v3.1.2.10.
- Xcode (macOS)
- Visual Studio 2017+ with C++ (Windows)
- Python 3.6+
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.
- (macOS) Download SDK Agora Video SDK for macOS. Unzip the downloaded SDK package and copy the
AograRtcEngineKit.framework
fromlibs
folder into the repository root folder. - (Windows) Download SDK Agora Video SDK for Windows. Unzip the downloaded SDK package and copy the
agora_rtc_sdk.dll
andagora_rtc_sdk.lib
files fromlibs/x86_64
(64-bit) orlibs/x86
(32-bit) into repository root folder.
- (macOS) Download SDK Agora Video SDK for macOS. Unzip the downloaded SDK package and copy the
-
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 tosite-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
andAgoraRtcKit.framework
oragora_rtc_sdk.dll
andagora_rtc_sdk.lib
to yoursite-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:
- Create a developer account at agora.io. Once you finish the sign-up process, you are redirected to the dashboard.
- Navigate in the dashboard tree on the left to Projects > Project List.
- Copy the app ID that you obtained from the dashboard into a text file. You will use it when you call our SDK.