Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't import RtlSdr #7

Closed
coolchevy opened this issue Dec 21, 2012 · 49 comments
Closed

can't import RtlSdr #7

coolchevy opened this issue Dec 21, 2012 · 49 comments

Comments

@coolchevy
Copy link

>>> from rtlsdr import RtlSdr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rtlsdr/__init__.py", line 1, in <module>
    from librtlsdr import librtlsdr
  File "rtlsdr/librtlsdr.py", line 35, in <module>
    f = librtlsdr.rtlsdr_get_device_count
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, rtlsdr_get_device_count): symbol not found

Sorry, it is may be my local issue?

@roger-
Copy link
Collaborator

roger- commented Dec 26, 2012

Seems like it might be an OSX or Python 2.6 ctypes issue (I haven't tested on either). Have you tried with Python 2.7?

@CaptainMcCrank
Copy link

I get the same error in 2.7:

from rtlsdr import *
Traceback (most recent call last):
File "", line 1, in
File "rtlsdr/init.py", line 1, in
from librtlsdr import librtlsdr
File "rtlsdr/librtlsdr.py", line 35, in
f = librtlsdr.rtlsdr_get_device_count
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/init.py", line 378, in getattr
func = self.getitem(name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/init.py", line 383, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, rtlsdr_get_device_count): symbol not found

@roger-
Copy link
Collaborator

roger- commented Feb 4, 2013

Strange, seems like their might be an issue with your librtlsdr library.

What happens if you type python librtlsdr.py?

@karlp
Copy link

karlp commented Dec 3, 2013

It doesn't respect LD_LIBRARY_PATH, and is really just saying that it can't find the library.

I had to do..

    driver_files += ['..//rtlsdr.dll', '//home//karlp//.local//lib//librtlsdr.so']

in load_librtlsdr() to make it work...

Also, just straight up ctypes.cll.LoadLibrary("librtlsdr.so.0" works better for me than the util.find_library stuff...

@emf
Copy link

emf commented Mar 14, 2014

I can't get this to load either.
"ImportError: Error loading librtlsdr. Make sure librtlsdr (and all of its dependencies) are in your path"

Trying to manually walk through the steps that load_librtlsdr() goes through, and using karlp's suggestions help nail it down a little closer:

from ctypes import cdll
cdll.LoadLibrary("/usr/local/lib/librtlsdr.0.dylib")
Traceback (most recent call last):
File "", line 1, in
File "/Users/emf/anaconda/lib/python2.7/ctypes/init.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/Users/emf/anaconda/lib/python2.7/ctypes/init.py", line 365, in init
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/librtlsdr.0.dylib, 6): Symbol not found: _libusb_alloc_transfer
Referenced from: /usr/local/lib/librtlsdr.0.dylib
Expected in: flat namespace
in /usr/local/lib/librtlsdr.0.dylib

@roger-
Copy link
Collaborator

roger- commented Mar 16, 2014

@emf: can you verify that any of the programs included with librtlsdr work? Sounds like you may have a libusb issue too.

@stupoo
Copy link

stupoo commented Jun 27, 2014

Hello,

I'm getting the very same problem, i'm on slackware 14.1 with 32bit libraries installed.

I can see the file in the python dir as follows

/usr/lib64/python2.7/site-packages/ | grep rtl

shows

pyrtlsdr-0.1.1-py2.7.egg

is that the correct file and location ?

Sorry I'm not very Python aware :-)

Stuart

@stupoo
Copy link

stupoo commented Jun 27, 2014

By the way if I run "rtl_test" I get the following.

bash-4.2# rtl_test
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
^CSignal caught, exiting!

User cancel, exiting...
Samples per million lost (minimum): 0

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

Are your Python and librtlsdr installations both 32 bit? That might be the issue.

BTW the latest version is 0.2.0. Try running pip install pyrtlsdr --upgrade (assuming you have pip).

@stupoo
Copy link

stupoo commented Jun 27, 2014

Thanks for the quick reply,

All my base packages are 64 bit as 14.1 has dropped 32bit from the install, I had to install the 32bit multilib stuff for MPLABX .

I dont think pip is on my system , is it totaly awsome and worth having ? :-)

I used http://slackbuilds.org/ for some of the required packages, I've noticed some arn't the latest version so I have been uninstalling and updating them with a fresh build from source.

I re downloaded the 0.2.0

hears the install output, all looks ok (I think)

bash-4.2$ sudo python setup.py install
Password:
running install
running bdist_egg
running egg_info
writing pyrtlsdr.egg-info/PKG-INFO
writing top-level names to pyrtlsdr.egg-info/top_level.txt
writing dependency_links to pyrtlsdr.egg-info/dependency_links.txt
reading manifest file 'pyrtlsdr.egg-info/SOURCES.txt'
writing manifest file 'pyrtlsdr.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/rtlsdr
copying rtlsdr/librtlsdr.py -> build/lib/rtlsdr
copying rtlsdr/helpers.py -> build/lib/rtlsdr
copying rtlsdr/init.py -> build/lib/rtlsdr
copying rtlsdr/rtlsdr.py -> build/lib/rtlsdr
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/rtlsdr
copying build/lib/rtlsdr/librtlsdr.py -> build/bdist.linux-x86_64/egg/rtlsdr
copying build/lib/rtlsdr/helpers.py -> build/bdist.linux-x86_64/egg/rtlsdr
copying build/lib/rtlsdr/init.py -> build/bdist.linux-x86_64/egg/rtlsdr
copying build/lib/rtlsdr/rtlsdr.py -> build/bdist.linux-x86_64/egg/rtlsdr
byte-compiling build/bdist.linux-x86_64/egg/rtlsdr/librtlsdr.py to librtlsdr.pyc
byte-compiling build/bdist.linux-x86_64/egg/rtlsdr/helpers.py to helpers.pyc
byte-compiling build/bdist.linux-x86_64/egg/rtlsdr/init.py to init.pyc
byte-compiling build/bdist.linux-x86_64/egg/rtlsdr/rtlsdr.py to rtlsdr.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrtlsdr.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrtlsdr.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrtlsdr.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrtlsdr.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/pyrtlsdr-0.2.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pyrtlsdr-0.2.0-py2.7.egg
Copying pyrtlsdr-0.2.0-py2.7.egg to /usr/lib64/python2.7/site-packages
Removing pyrtlsdr 0.1.1 from easy-install.pth file
Adding pyrtlsdr 0.2.0 to easy-install.pth file

Installed /usr/lib64/python2.7/site-packages/pyrtlsdr-0.2.0-py2.7.egg
Processing dependencies for pyrtlsdr==0.2.0
Finished processing dependencies for pyrtlsdr==0.2.0


When I start the program :

bash-4.2$ ./rtlsdr_scan.py
Traceback (most recent call last):
File "./rtlsdr_scan.py", line 36, in
import rtlsdr
File "build/bdist.linux-x86_64/egg/rtlsdr/init.py", line 18, in

File "build/bdist.linux-x86_64/egg/rtlsdr/librtlsdr.py", line 52, in
File "/usr/lib64/python2.7/ctypes/init.py", line 378, in getattr
func = self.getitem(name)
File "/usr/lib64/python2.7/ctypes/init.py", line 383, in getitem
func = self._FuncPtr((name_or_ordinal, self))

AttributeError: python: undefined symbol: rtlsdr_get_device_count

Hears the $PATH output incase thats helpful

bash-4.2$ echo $PATH
/usr/local/bin
:/usr/bin
:/bin
:/usr/games
:/opt/blender
:/usr/lib64/java/bin
:/usr/lib64/java/jre/bin
:/usr/lib64/kde4/libexec

:/usr/lib64/qt/bin:/usr/share/texmf/bin

I tried

bash-4.2$ export PATH=$PATH:/usr/lib64/python2.7/site-packages

in case this was a problem, didn't make a difference.

I saw the post above by KARLP , but didn't quite understand what he was saying.

Thanks,

Stuart

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

Hmm... rtlsdr_get_device_count() should be in librtlsdr.so, so I'm not sure why it's complaining.

Can you run nm -D /usr/lib/librtlsdr.so (the exact path might differ on your system) and see if it lists rtlsdr_get_device_count? Maybe your librtlsdr is really outdated? I don't think the API has changed recently.

Also you can try deleting these lines from librtlsdr.py (wherever it's installed):

f = librtlsdr.rtlsdr_get_device_count
f.restype, f.argtypes = c_uint, []

Then try again.

@stupoo
Copy link

stupoo commented Jun 27, 2014

Ok I found the librtlsdr.so (I had to read man find as always)

/usr/local/lib/librtlsdr.so

I ran nm -D /usr/local/lib/librtlsdr.so

0000000000004420 T rtlsdr_get_device_count
shows up,
full output below


             w _ITM_deregisterTMCloneTable
             w _ITM_registerTMCloneTable
             w _Jv_RegisterClasses

000000000020d920 B bss_start
w __cxa_finalize
w __gmon_start

000000000020d920 D _edata
000000000020d930 B _end
0000000000009ff8 T _fini
0000000000001d98 T _init
U fprintf
U free
U fwrite
U libusb_alloc_transfer
U libusb_bulk_transfer
U libusb_cancel_transfer
U libusb_claim_interface
U libusb_close
U libusb_control_transfer
U libusb_exit
U libusb_free_device_list
U libusb_free_transfer
U libusb_get_device
U libusb_get_device_descriptor
U libusb_get_device_list
U libusb_get_string_descriptor_ascii
U libusb_handle_events_timeout
U libusb_init
U libusb_kernel_driver_active
U libusb_open
U libusb_release_interface
U libusb_reset_device
U libusb_submit_transfer
U malloc
U memcpy
0000000000005300 T rtlsdr_cancel_async
0000000000004e60 T rtlsdr_close
00000000000035b0 T rtlsdr_get_center_freq
0000000000004420 T rtlsdr_get_device_count
00000000000044e0 T rtlsdr_get_device_name
0000000000004630 T rtlsdr_get_device_usb_strings
0000000000003f70 T rtlsdr_get_direct_sampling
0000000000003670 T rtlsdr_get_freq_correction
0000000000004770 T rtlsdr_get_index_by_serial
0000000000004400 T rtlsdr_get_offset_tuning
0000000000003c60 T rtlsdr_get_sample_rate
0000000000003b20 T rtlsdr_get_tuner_gain
00000000000036b0 T rtlsdr_get_tuner_gains
0000000000003690 T rtlsdr_get_tuner_type
0000000000002fc0 T rtlsdr_get_usb_strings
0000000000002db0 T rtlsdr_get_xtal_freq
0000000000004800 T rtlsdr_open
0000000000004f50 T rtlsdr_read_async
0000000000003410 T rtlsdr_read_eeprom
0000000000004f20 T rtlsdr_read_sync
0000000000004ed0 T rtlsdr_reset_buffer
0000000000003cb0 T rtlsdr_set_agc_mode
00000000000034d0 T rtlsdr_set_center_freq
0000000000003ce0 T rtlsdr_set_direct_sampling
00000000000035d0 T rtlsdr_set_freq_correction
0000000000003f90 T rtlsdr_set_offset_tuning
00000000000040c0 T rtlsdr_set_sample_rate
0000000000003c80 T rtlsdr_set_testmode
0000000000003a80 T rtlsdr_set_tuner_gain
0000000000003bd0 T rtlsdr_set_tuner_gain_mode
0000000000003b40 T rtlsdr_set_tuner_if_gain
00000000000042f0 T rtlsdr_set_xtal_freq
00000000000052f0 T rtlsdr_wait_async
00000000000032e0 T rtlsdr_write_eeprom
U stderr
U strcmp
U usleep

@stupoo
Copy link

stupoo commented Jun 27, 2014

With regard to this bit , it dosn't seem to have installed that file corectly , I just did a find and it's only showing in the src directories not any library dir.

or did you meen to change that file and run the install again ?

Sorry for being a bit slow,

Stuart

Also you can try deleting these lines from librtlsdr.py (wherever it's installed):

f = librtlsdr.rtlsdr_get_device_count
f.restype, f.argtypes = c_uint, []

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

Odd that librtlsdr.so seems fine.

Can you run this in a Python shell and give me the output:

from ctypes import *
from ctypes.util import find_library

print find_library('rtlsdr'), find_library('librtlsdr')

dll = CDLL("/usr/local/lib/librtlsdr.so")

print dll
print dll.rtlsdr_get_device_count

The file librtlsdr.py should definitely be somewhere on your computer if you have pyrtlsdr installed. You could try modifying the source file from the installation package and re-installing.

@stupoo
Copy link

stupoo commented Jun 27, 2014

ok Python shell , thats new to me :-)

I ran it hears the copy and paste

from ctypes import *
from ctypes.util import find_library
print find_library('rtlsdr'), find_library('librtlsdr')
librtlsdr.so.0 None
dll = CDLL("/usr/local/lib/librtlsdr.so")
print dll
<CDLL '/usr/local/lib/librtlsdr.so', handle 266a5f0 at 7f56923d8d90>
print dll.rtlsdr_get_device_count
<_FuncPtr object at 0x7f5692333460>

to my inexperianced python eye it looks like it couldn't find an .so lib but found it as a .dll

now i'm totaly confused :-)

Stuart

@stupoo
Copy link

stupoo commented Jun 27, 2014

I've also re ran the python install for the rtlsdr with python instal.py install_lib

now I have

/usr/lib64/python2.7/site-packages/rtlsdr/librtlsdr.py

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

How about this:

from ctypes import *
from ctypes.util import find_library

file_name = find_library('rtlsdr')
dll = CDLL(file_name)

print dll
print dll.rtlsdr_get_device_count

@stupoo
Copy link

stupoo commented Jun 27, 2014

Hello,

Just did that hears the copy and paste

from ctypes import *
from ctypes.util import find_library
file_name = find_library('rtlsdr')
dll = CDLL(file_name)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.7/ctypes/init.py", line 365, in init
self._handle = _dlopen(self._name, mode)
OSError: librtlsdr.so.0: cannot open shared object file: No such file or directory
print dll
Traceback (most recent call last):
File "", line 1, in
NameError: name 'dll' is not defined
print dll.rtlsdr_get_device_count
Traceback (most recent call last):
File "", line 1, in
NameError: name 'dll' is not defined

Thanks for the help by the way,

Stuart

@stupoo
Copy link

stupoo commented Jun 27, 2014

I found the lines in the .py file in the python librarys and commented out the lines you suggested , it didn't seem to change the error so I put them back.

Stuart

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

Ok, I believe I know what's wrong. Try this:

import ctypes
from ctypes.util import find_library

file_name = find_library('rtlsdr')
dll = ctypes.cdll.LoadLibrary(file_name)

print dll
print dll.rtlsdr_get_device_count

@stupoo
Copy link

stupoo commented Jun 27, 2014

ok done that hears the copy and paste

bash-4.2# python
Python 2.7.5 (default, May 29 2013, 02:28:51)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import ctypes
from ctypes.util import find_library
file_name = find_library('rtlsdr')
dll = ctypes.cdll.LoadLibrary(file_name)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.7/ctypes/init.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib64/python2.7/ctypes/init.py", line 365, in init
self._handle = _dlopen(self._name, mode)
OSError: librtlsdr.so.0: cannot open shared object file: No such file or directory
print dll
Traceback (most recent call last):
File "", line 1, in
NameError: name 'dll' is not defined
print dll.rtlsdr_get_device_count
Traceback (most recent call last):
File "", line 1, in
NameError: name 'dll' is not defined

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

Maybe you don't have /usr/local/lib/ in your LD_LIBRARY_PATH environment.

Try running echo $LD_LIBRARY_PATH in a shell. If you don't see /usr/local/lib/ then it needs to be added.

@stupoo
Copy link

stupoo commented Jun 27, 2014

Indeed ,
I did , export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
:-) Sorry for the long journey you have been on to help me.

I feel a little silly and can only hope this helps someone else also :-)

Many many Thanks,

Interestingly my $LD_LIBRARY_PATH was totally empty , I will read up on weather this is normal for my distro (slackware 14.1 x64)

Stuart.

@roger-
Copy link
Collaborator

roger- commented Jun 27, 2014

No problem, glad you got it working and I can close this issue :)

I'll add the stuff about LD_LIBRARY_PATH in the README in case other people have the same issue.

Cheers,
Roger

@roger- roger- closed this as completed Jun 27, 2014
@sbfreddie
Copy link

Roger:
I have a similar problem on Ubuntu 12.04 on armhfv7.
No matter what I do I cannot get the load LD_LIBRARY_PATH to work. It seems that Ubuntu does not allow you to set the LD_LIBRARY_PATH, I guess its some sort of bug that was never fixed.

Thanks for any advice,
Freddie

@roger-
Copy link
Collaborator

roger- commented Aug 3, 2014

I see no reason why it would be any different in Ubuntu, have you tried export LD_LIBRARY_PATH="/path_to_libs/"?

@sbfreddie
Copy link

Roger:
Thanks, for getting back to me. Yes, setting the LD_LIBRARY_PATH in the terminal works, but only while that particular terminal window is open, if you close the terminal window and open another one later you have to export the LD_LIBRARY_PATH again.
But at this juncture the point is moot because I have not been able to get pyrtlsdr to work no matter what I do. Even thought I have followed all the instructions carefully, and during installation there are no errors I still cannot get it to work.
I have searched the entire disk and after installation "locate rtlsdr_scan.py" produces nothing.
After installation I tried "waterfall_test" and it seems to work OK, but that is the only thing that works.

Thanks,
Freddie

@roger-
Copy link
Collaborator

roger- commented Aug 3, 2014

See here, for example, to see how to do it permanently.

rtlsdr_scan.py isn't a part of pyrtlsdr, so you probably didn't install RTLSDR-Scanner correctly (that's completely separate from this project).

If demo_waterfall.py or test.py work, then it sounds like you've installed pyrtlsdr correctly.

@sbfreddie
Copy link

Roger:
Thanks, for helping me to understand.
I'm sorry for the static on this channel.

Freddie

@roger-
Copy link
Collaborator

roger- commented Aug 4, 2014

No prob, hope you get it working.

@sotonian
Copy link

Hopefully roger- is still monitoring..

I'm trying to get TinyPython|Panadapter going, eventually on a Raspberry Pi2, but to start with on my desktop (ubuntu-mate 15.10). When I run pyrtlsdr's setup.py I get a compile error (see below regarding the caret location):
..... python setup.py install
running install
running build
running build_py
running install_lib
byte-compiling /usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py to rtlsdraio.pyc
File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py", line 15
def init(self, func_start, func_stop=None, queue_size=20, *, loop=None):
.............................................................................................^
SyntaxError: invalid syntax

running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/pyrtlsdr-0.1.1.egg-info
Writing /usr/local/lib/python2.7/dist-packages/pyrtlsdr-0.1.1.egg-info

`
The caret is under the , following the * - I'm not sure if github will upset the dot formatting I've added.

I'm no python expert - one idea of this is to learn more about it - so I'm puzzled by this message. My books and searching around haven't helped. I had to change the permissions on /usr/local/lib/python2.7/dist-packages/pyrtlsdr-0.1.1.egg-info so the setup could change it.

I've done the export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib as it wasn't on the path

Ideas welcome, TIA

Chris

@roger-
Copy link
Collaborator

roger- commented Feb 10, 2016

Oh it looks like that's a Python 2.7 issue that I need to fix. In the mean time just remove * and see if that works.

@nocarryr
Copy link
Collaborator

@roger- Yup, those unpacking generalizations introduced in py3.5 are difficult to make backwards compatible.
I haven't looked through all of the code, but it looks like this is the only place that class is instantiated:

self.async_iter = AsyncCallbackIter(func_start=lambda cb: func_start(cb, num_samples_or_bytes),
                                            func_stop=self.cancel_read_async,
                                            loop=loop)

Since the arguments are all named it would seem that the additional * unpack could be dropped, but I'd assume you put that there intentionally.

@sotonian
Copy link

Thanks for the quick reply, much appreciated.

If I remove * and the , I get another error further down:

`byte-compiling /usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py to rtlsdraio.pyc
File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py", line 59
async def aiter(self):
..............^

SyntaxError: invalid syntax

`
[github has removed the double underlines around aiter]

If I remove just the * I see:

byte-compiling /usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py to rtlsdraio.pyc File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdraio.py", line 15 def __init__(self, func_start, func_stop=None, queue_size=20, , loop=None): ...........................................^ SyntaxError: invalid syntax

Chris

@nocarryr
Copy link
Collaborator

Ok, so the solution that I came up with here to avoid importing rtlsdraio in incompatible environments only seems to cover cases where the library isn't being installed from pip (git clones only).

An alternative may need to be found, perhaps modifying setup.py for Python < 3.5?

@nocarryr
Copy link
Collaborator

@roger- I may have time later on today to play around with setuptools on my fork (and maybe even build some tests with TravisCI across different versions).

@sotonian
Copy link

@nocarryr - thanks for your replies. The file init.py (with underscores) is present in the rtlsdr directory below setup.py along with rtlsdraio et al. I didn't (knowingly) use pip, I got the source via a git clone from the roger- repository

@roger-
Copy link
Collaborator

roger- commented Feb 12, 2016

@nocarryr

Yeah the * isn't really necessary, it just forces the async loop parameter to be keyword only. It's more of a convention it seems

Thanks for your help with this, will merge your fix.

@nocarryr
Copy link
Collaborator

👍

@roger- I started some work on automated tests with travis-ci btw:
https://github.com/nocarryr/pyrtlsdr/tree/ci-testing
build history:
https://travis-ci.org/nocarryr/pyrtlsdr/builds

Running the tests themselves would be a bit difficult though without the device present in the build environment, but I'm hoping to find ways of at least having it test for issues like this one... eventually even have tests run with a 'dummy' device

@roger-
Copy link
Collaborator

roger- commented Feb 12, 2016

I don't have any travis experience, but looks like a good thing to have!

@nocarryr
Copy link
Collaborator

I didn't either until recently. I just decided I wanted to figure it out one day to fix stuff on another project. I'm not an expert by any means, but it's fun to learn

@electroconvulsivo
Copy link

I'm not sure if this is the place for this... I had an issue: "undefined symbol: rtlsdr_set_bias_tee"

Solved it with export LD_LIBRARY_PATH="/path_to_libs/"

Many thanks!

@yangtianlei
Copy link

In my case, I don't have the librtlsdr.so.
To fix that,if in Debain/Ubuntu:
$sudo apt-get install librtlsdr-dev
if in CentOS:
$sudo yum install rtl-sdr-devel
Hope it works.

@ET313
Copy link

ET313 commented Jan 15, 2019

Dear Roger,
I have Windows10 64 bit, Python 3.7.1 with Anaconda3 2018.12 64-bit and run
python setup.py install
pip install pyrtlsdr –-upgrade
(base) D:\pyrtlsdr-master>pip install pyrtlsdr --upgrade
Requirement already up-to-date: pyrtlsdr in c:\programdata\anaconda3\lib\site-packages\pyrtlsdr-0.2.91-py3.7.egg (0.2.91)

I tried in Anaconda Prompt:
(base) D:\pyrtlsdr-master>python test.py
Traceback (most recent call last):
File "test.py", line 62, in
main()
File "test.py", line 29, in main
sdr = RtlSdr()
File "D:\pyrtlsdr-master\rtlsdr\rtlsdr.py", line 133, in init
self.open(device_index, test_mode_enabled, serial_number)
File "D:\pyrtlsdr-master\rtlsdr\rtlsdr.py", line 172, in open
% (result, device_index))
OSError: Error code -1 when opening SDR (device index = 0)

(base) D:\pyrtlsdr-master>

or tried our own small myrtldsr.py with content:
import rtlsdr
sdr = RtlSdr()

with this result in pyrtlsdr-master directory:
(base) D:\pyrtlsdr-master>python myrtlsdr.py
Traceback (most recent call last):
File "myrtlsdr.py", line 2, in
sdr = RtlSdr()
NameError: name 'RtlSdr' is not defined

and in the other directory:
(base) D:\pyrtlsdr-master\build\lib\rtlsdr>python myrtlsdr.py
Traceback (most recent call last):
File "myrtlsdr.py", line 1, in
import rtlsdr
File "D:\pyrtlsdr-master\build\lib\rtlsdr\rtlsdr.py", line 20, in
from .librtlsdr import (
ImportError: attempted relative import with no known parent package

or trying your python files:
(base) D:\pyrtlsdr-master\build\lib\rtlsdr>python rtlsdr.py
Traceback (most recent call last):
File "rtlsdr.py", line 20, in
from .librtlsdr import (
ModuleNotFoundError: No module named 'main.librtlsdr'; 'main' is not a package

(base) D:\pyrtlsdr-master\build\lib\rtlsdr>python librtlsdr.py

(base) D:\pyrtlsdr-master\build\lib\rtlsdr>

Could you please help?

@nocarryr
Copy link
Collaborator

nocarryr commented Jan 15, 2019

@ET313 The first error you had:

OSError: Error code -1 when opening SDR (device index = 0)

Is most likely an issue with device drivers and the librtldsr installation. I would recommend running the rtl_test program shipped with the library to see if it communicates with your device.

The second one is just an import issue:

import rtlsdr
sdr = RtlSdr()

Should be:

import rtlsdr
sdr = rtldsr.RtlSdr()

@ET313
Copy link

ET313 commented Jan 16, 2019

many thanks for helping at import issue!
Running rtl_test.exe program this is the result:
Found 1 device(s):
0: ¶â, , SN: ¹

Using device 0: Terratec T Stick PLUS
usb_open error -5
Failed to open rtlsdr device #0.

could you help?

@nocarryr
Copy link
Collaborator

Hmmm. The description of the error code is "LIBUSB_ERROR_NOT_FOUND" (which isn't very helpful)
Your device is listed as being supported and uses the E4000, but I don't have much else to go off of.
I would check the wiki:
https://osmocom.org/projects/rtl-sdr/wiki/Rtl-sdr

As well as issues on librtldsr:
https://github.com/librtlsdr/librtlsdr

@RenatZvezdkin
Copy link

i think i found solution, you have to add Path in environmental variables to lib from this link
it worked for me
https://ftp.osmocom.org/binaries/windows/rtl-sdr/

@sotonian
Copy link

sotonian commented Jun 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests