On Jul 15, 2010, at 5:54 AM, Bruhtesfa Ebrahim wrote:
It is kind of confusing. I have Gnuradio installed, so executing the
gnuradio examples in their own directory works fine. But, from the
home
directory..it restult in:
$ python dial_tone.py
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
Resources/Python.app/Contents/MacOS/Python:
can't open file 'dial_tone.py': [Errno 2] No such file or directory
Let me see if I understand what you've written correctly:
* You installed GNU Radio in the standard way: bootstrap, configure,
make, make install. That means the examples ended up at "/usr/local/
share/gnuradio/examples", and in particular the one you mention at "/
usr/local/share/gnuradio/examples/audio/dial_tone.py".
* "PYTHONPATH=/opt/local/lib/python2.6/site-packages:/usr/local/lib/
python2.6/site-packages" for your shell environment.
* When your shell's directory has been changed "cd /usr/local/share/
gnuradio/examples/audio" and you then do "python dial_tone.py" it
works for you.
* When your shell's directory is it's "home" (typically on OSX "/Users/
FOO", where FOO is your username; also called "~"), then issuing the
same command ("python dial_tone.py") does not work for you because the
script is not found.
All of the above is normal behavior for Linux and pretty much any UNIX
flavor including OSX, and it sounds like GNU Radio is installed
correctly.
The issue is that the script "dial_tone.py" is not in the search path
that Python knows (via the PYTHONPATH & what else is built in to
Python). If you do issue "python -c 'import sys; print sys.path'"
you'll see what Python thinks of as its search path. The first entry
is probably '', which corresponds to "." or the directory from which
Python was called. After that are the directories listed in
PYTHONPATH, and then the rest are those stored in the Python install
at compile-time.
If you want to execute the script you mention from your home
directory, you'll need to reference it directly, e.g., "python /usr/
local/share/gnuradio/examples/audio/dial_tone.py" should work. Or, if
you want to use that script a lot from other locations, you can always
add its directory to the PYTHONPATH; it'd recommend doing it at the
end, via adding ":/usr/local/share/gnuradio/examples/audio" to what's
already there.
Also of note: As with Linux and other UNIX flavors, on OSX you
generally don't actually need the "python" declaration in front of the
file so long as the file is marked executable. As with your example,
if you do "ls -l /usr/local/share/gnuradio/examples/audio/
dial_tone.py" it should come back marked as "x" for everyone (meaning:
executable). Hence you could just do "/usr/local/share/gnuradio/
examples/audio/dial_tone.py" from anywhere, or "cd /usr/local/share/
gnuradio/examples/audio && ./dial_tone.py" and it should function
correctly. Even GUI Python scripts should work correctly without the
"pythonw" in front -- though there will be a few stubborn ones that
will complain.
Hope this helps! - MLD
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio