On Wed, 20 Apr 2011 17:47:57 -0700 Nick Foster <n...@ettus.com> wrote:
> On Thu, 2011-04-21 at 08:37 +0800, Yulong Yang wrote: > > Hello, > > > > I have tried both python -c "import..." and echo $. I see the path > > to my folder in both of them. But it still says ImportError in > > top_block.py. Where exactly should the path direct to? I tried both > > "~/gnuradio" and "~/gnuradio/myblock". > > > > When you say __init__.py do you mean the one in sub-folder > > "python"? I find this comment in that file: # The presence of this > > file turns this directory into a Python package. > > > > I am wondering where I could see the declare of my module. > > How did you create your project? Did you use > "create-gnuradio-out-of-tree-project myblock"? If you did, you should > be able to: > > cd myblock > ./bootstrap > ./configure > make > sudo make install > > and then > python -c "import myblock" > > Otherwise, you're going to have to go into the howto-write-a-block > directory which you cloned, and edit the SWIG stuff to change all the > "howto" references to "myblock", and that is going to be a pain. Try > re-creating your project using create-gnuradio-out-of-tree-project, > it's the recommended way to start your own block project. > > --n > Actually my block folder is copied from a wiki tutorial here: http://gnuradio.org/redmine/wiki/gnuradio/More_examples I tried create-out-of-tree command, it seems to download the newest how-to block from the gnuradio site and make it into the path I create it, right? In the folder, it looks the same with the default folder "gr-howto-write-a-block". Do you mean I should add my own block besides the already exist files like howto_square_ff.cc? > > > > To Mike: yes, I am in Ubuntu 10.04 > > > > Many thanks to your help. > > > > On Wed, 2011-04-20 at 16:43 -0700, Josh Blum wrote: > > > > > > On 04/20/2011 04:42 PM, yulong yang wrote: > > > > On Thu, Apr 21, 2011 at 7:17 AM, Josh Blum <j...@joshknows.com> > > > > wrote: > > > > > > > >> > > > >> > > > >> On 04/20/2011 03:00 AM, Yulong Yang wrote: > > > >>> Hello, > > > >>> > > > >>> I am new to GNU radio. I am trying to write a simple block > > > >>> and add it to GRC. All steps before are fine. However, when I > > > >>> generate the top_block.py file, it says "ImportError: No > > > >>> module named myblock". > > > >>> > > > >>> The myblock is actually the name of the folder I create to > > > >>> put all necessary files of my block such as files like > > > >>> MakeFile.am and sub-folders lib, swig, etc. Can this be > > > >>> called a module? > > > >>> > > > >> > > > >> In the case of python, a module is a python file or a > > > >> directory w/ a python file __init__.py > > > >> > > > > > > > > Thank your for your reply. > > > > > > > > So for example, the how-to--write-a-block folder stands for a > > > > module called "howto", right? Is the name of the module defined > > > > in the py file? > > > > > > > >> > > > >>> What is a module? I see the code in how-to-write-a-block, it > > > >>> seems that it also import a module howto. Where could I find > > > >>> such modules or create one my own? > > > >>> > > > >>> Sorry to ask so many questions; I cannot find a clear way to > > > >>> study this. I would really appreciate any help. > > > >>> > > > >>> Thank you in advance. > > > >>> > > > >>> > > > >> > > > >> Python needs to be able to find your block: Did you install it > > > >> into the python search path? Or set PYTHONPATH to where your > > > >> block is installed? > > > >> > > > >> > > > > Do your mean PYTHONPATH or just system search path? > > > > I have set my block path as the PYTHONPATH in ~/.profile, but > > > > it still cannot work. Is there a way to check whether the path > > > > is set appropriately? > > > > > > > > > > try .bashrc > > > > > > also > > > > > > python -c "import sys; print sys.path" > > > > > > > > > > >> -josh > > > >> > > > >> _______________________________________________ > > > >> Discuss-gnuradio mailing list > > > >> Discuss-gnuradio@gnu.org > > > >> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio > > > >> > > > > > > > > > > > > _______________________________________________ > > Discuss-gnuradio mailing list > > Discuss-gnuradio@gnu.org > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio > > _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio