问题
I am trying to create softphone using Python. I found this link describing pjsua2 but there are no any clear steps that define how to install pjsua2 package for python.
Can any one please define me clear steps on installing pjsua2 that can be used in python ?
回答1:
These steps shall work
Step1: Create a directory. /PJSUA2/pjproject/src
Step2: install required modules
sudo apt-get install libasound2-dev libssl-dev libv4l-dev libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libx264-dev libavformat-dev libavcodec-dev libavdevice-dev libavfilter-dev libavresample-dev libavutil-dev libavcodec-extra libopus-dev libopencore-amrwb-dev libopencore-amrnb-dev libvo-amrwbenc-dev subversion
Step 3: Download source code svn co http://svn.pjsip.org/repos/pjproject/trunk pjproject
Step 4: Compile main library and install. If you are trying it on RPI, refer to this link. Basically you need to set proper CFLAGS and ensure third_party/build/os-auto.mak.in is properly configured for your platform.
$ cd pjproject
$ ./configure --enable-shared
$ make dep
$ make
$ sudo make install
Step 5: Compile and install python module. Again ensure you have proper user.mak, if you are compiling it for RPI
$ cd pjsip-apps/src/swig/
$ make
$ make install
Step 6: Check installed module
$ python
> import pjsua2
These steps are exactly mentioned here, except for that RPI twist
Update #1:
And dont forget to set ep_cfg.uaConfig.threadCnt = 0
, else you will get Segmentation fault
. So the sample code in PJSUA2 page shall have change
def pjsua2_test():
# Create and initialize the library
ep_cfg = pj.EpConfig()
ep_cfg.uaConfig.threadCnt = 0; #Python does not like PJSUA2's thread. It will result in segment fault
ep = pj.Endpoint()
ep.libCreate()
ep.libInit(ep_cfg)
回答2:
The steps look like they are listed here: https://trac.pjsip.org/repos/wiki/Python_SIP/Build_Install
I ran through them and they seemed to work without any problem on Mac Os X. What as the exact issue you were running into?
回答3:
Usually you just need to go to your Command Line and type in :
pip install [packagename]
So, in this case, its probably:
pip install pjsua2
Then just import pjsua2
in python
来源:https://stackoverflow.com/questions/53736284/how-to-install-pjsua2-packages-for-python