最近在Mac上研究rtlsdr。本来期望使用高大上的Matlab来学习的。可是Matlab上的素材实在太偏学术,羞涩难懂,不得已转到Python上学习。
在电脑上部署了conda+pycharm环境后。运行python的示例程序,结果报了一堆错误。将代码缩减到仅仅只是import rtlsdr,还是报错
>>> import rtlsdr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/weidong/opt/anaconda3/lib/python3.7/site-packages/rtlsdr/__init__.py", line 56, in <module>
from .librtlsdr import librtlsdr
File "/Users/weidong/opt/anaconda3/lib/python3.7/site-packages/rtlsdr/librtlsdr.py", line 61, in <module>
f = librtlsdr.rtlsdr_get_device_count
File "/Users/weidong/opt/anaconda3/lib/python3.7/ctypes/__init__.py", line 377, in __getattr__
func = self.__getitem__(name)
File "/Users/weidong/opt/anaconda3/lib/python3.7/ctypes/__init__.py", line 382, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, rtlsdr_get_device_count): symbol not found
查了各种资料,发现可能跟Mac环境有关,缺个库librtlsdr。而这个库在pip的时候不会自动导入。需要brew一下。于是运行
brew install librtlsdr
搞定!