pjsua2网上很多教程都安装失败,记录下正确的安装过程。
pip命令安装会提示如下错误:
(pjsip) [root@L-AP-10-88 ~]# pip3 install pjsua2
Collecting pjsua2
Using cached pjsua2-2.12.tar.gz (329 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [7 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-4kwezv0a/pjsua2_9cd1d7f4f4ad418dacfdefe37f23ef90/setup.py", line 33, in <module>
f = open('../../../../version.mak', 'r')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '../../../../version.mak'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
采用编译的方式安装:
wget https://github.com/pjsip/pjproject/archive/refs/tags/2.15.1.tar.gz
tar -zxvf ./2.15.1.tar.gz
cd pjproject-2.15.1/
ls
./configure --enable-shared --with-python=python3
make dep
make
make install
ldconfig
# 下一步前需要安装swig,根据操作系统采用1或者2的方式
#1 ubuntu 直接安装
apt-get install swig python3-dev
#2 centos 采用包安装
# 下载 SWIG 4.0.2
wget https://download.sourceforge.net/swig/swig-4.0.2.tar.gz
# 解压
tar xvf swig-4.0.2.tar.gz
cd swig-4.0.2
# 配置、编译并安装
./configure --prefix=/usr/local
make
sudo make install
# 检查是否安装成功
swig -version
# 这步非常重要,特别是路径
cd pjsip-apps/src/swig/python
make
python3 setup.py build
验证pjsua2
(pjsip) [root@L-AP-10-88 ~]# python
Python 3.8.20 (default, Oct 3 2024, 15:24:27)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pjsua2
参考文档:
https://github.com/pjsip/pjproject/issues/4126
https://docs.pjsip.org/en/latest/pjsua2/building.html#building-python-swig-module
566

被折叠的 条评论
为什么被折叠?



