# Basic python question

**URL:** <https://www.ruby-forum.com/t/basic-python-question/220367>\
**Category:** GNU Radio\
**Created:** [June 7, 2012, 5:28am UTC](https://www.ruby-forum.com/t/basic-python-question/220367 "2012-06-07T05:28:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 7, 2012, 5:28am UTC](https://www.ruby-forum.com/t/basic-python-question/220367/1 "2012-06-07T05:28:49Z")

</div>

I’m almost afraid to ask such a basic question. A Google search shows  
that the Internet is awash with all sorts of tutorials but I still  
haven’t discovered the answer.

It dawned on me a couple of days ago that gnuradio is not a plug-and  
-play SDR, like several of the Windows SDR applications that I’ve played  
with, but a series of building blocks. My journey into gnuradio came to  
a halt very quickly.

My question is, how do I tell Python (I’m using it from the command  
line, no IDE yet) where the modules are located? As in the following  
example.

> > > from rtlsdr import \*  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > ImportError: No module named rtlsdr

–  
Regards,  
Phil

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [June 7, 2012, 2:39pm UTC](https://www.ruby-forum.com/t/basic-python-question/220367/2 "2012-06-07T14:39:51Z")

</div>

Type $PYTHONPATH in bash what does it return? Also from the Python  
interpreter (type python in bash), type

import sys  
sys.path

What does this return?

They should return things like /usr/lib64 (and  
lib)/python2.7/site-packages and /usr/local/lib64 (and  
lib)/python2.7/site-packages.

So what python does when it looks for a module to import, it looks in  
those folders defined by pythonpath and sys.path. If you want to  
import a package that’s called rtlsdr, there should be a folder in one  
of the site-packages folders called rtlsdr. Additionally in that  
folder there should be a **init**.py file. That’s how finding modules  
works in a nutshell.

If you didn’t have a PYTHONPATH, type this into a bash prompt to set  
one (it will set for that user only)

export 1 \>\> $PYTHONPATH=/usr/local/lib64/python2.7/site-packages

reference: [6. Modules — Python 3.11.4 documentation](http://docs.python.org/tutorial/modules.html)

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [June 7, 2012, 3:02pm UTC](https://www.ruby-forum.com/t/basic-python-question/220367/3 "2012-06-07T15:02:40Z")

</div>

Oops that’s funny I muxed up the echo and export commands! This is what  
I meant:

export $PYTHONPATH="/usr/local/lib64/python2.7/site-packages"

On Thu, Jun 7, 2012 at 8:39 AM, Ryan Connelly
