概述
Documentation:
http:// https://pyrtlsdr.readthedocs.io
安装好pyrtldr库(pip insall ……)后,验证代码如下:
from rtlsdr import RtlSdr
sdr = RtlSdr()
# configure device
sdr.sample_rate = 2.048e6 # Hz
sdr.center_freq = 70e6 # Hz
sdr.freq_correction = 60 # PPM
sdr.gain = 'auto'
print(sdr.read_samples(512))
报错(ImportError: Error loading librtlsdr. Make sure librtlsdr (and all of its dependencies) are in your path):
Traceback (most recent call last):
File "D:VScodeRtlsdrtry1.py", line 2, in <module>
from rtlsdr import RtlSdr
File "D:AppCudacondalibsite-packagesrtlsdr__init__.py", line 56, in <module>
from .librtlsdr import librtlsdr
File "D:AppCudacondalibsite-packagesrtlsdrlibrtlsdr.py", line 50, in <module>
librtlsdr = load_librtlsdr()
File "D:AppCudacondalibsite-packagesrtlsdrlibrtlsdr.py", line 45, in load_librtlsdr
raise ImportError('Error loading librtlsdr. Make sure librtlsdr '
ImportError: Error loading librtlsdr. Make sure librtlsdr (and all of its dependencies) are in your path
原因:
1.没有在目录文件(文件配置环境)下放入相关的硬件驱动文件(加密狗)
文件相关链接:RTL utils
2.头文件内某些相对路径改为绝对路径
# driver_files += ['librtlsdr.so', 'rtlsdr/librtlsdr.so']
# driver_files += ['rtlsdr.dll', 'librtlsdr.so']
# driver_files += ['..//rtlsdr.dll', '..//librtlsdr.so']
# driver_files += ['rtlsdr//rtlsdr.dll', 'rtlsdr//librtlsdr.so']
# driver_files += [lambda : find_library('rtlsdr'), lambda :find_library('librtlsdr')]
driver_files += ['D:\App\Cuda\conda\Lib\site-packages\rtlsdr\librtlsdr.dll']
driver_files += ['D:\App\Cuda\conda\Lib\site-packages\rtlsdr\libusb-1.0.dll']
driver_files += ['D:\App\Cuda\conda\Lib\site-packages\rtlsdr\libwinpthread-1.dll']
完成相关步骤后,若再次报错(AttributeError: function 'rtlsdr_get_device_count' not found):
Traceback (most recent call last):
File "D:VScodeRtlsdrtry1.py", line 2, in <module>
from rtlsdr import *
File "D:AppCudacondalibsite-packagesrtlsdr__init__.py", line 56, in <module>
from .librtlsdr import librtlsdr
File "D:AppCudacondalibsite-packagesrtlsdrlibrtlsdr.py", line 64, in <module>
f = librtlsdr.rtlsdr_get_device_count
File "D:AppCudacondalibctypes__init__.py", line 395, in __getattr__
func = self.__getitem__(name)
File "D:AppCudacondalibctypes__init__.py", line 400, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'rtlsdr_get_device_count' not found
原因:
pyrtlsdr库本地安装时可能安装的不完整,需重新安装
链接:Releases · librtlsdr/librtlsdr · GitHub
我选择的是rtlsdr-bin-w64_static.zip,复制粘贴到配置环境文件夹(D:AppCudacondalibsite-packagesrtlsdr)中
参考文献(大多需翻墙):
python - pyrtlsdr on windows doesnt import - Stack Overflow
https://groups.google.com/g/sara-list/c/x6IpST8PBvs/m/NQh_YAp9AAAJ?utm_medium=email&utm_source=footer
最后
以上就是甜美电脑为你收集整理的SDR在windows环境下pyrtlsdr的安装的全部内容,希望文章能够帮你解决SDR在windows环境下pyrtlsdr的安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复