I'm new to GNU Radio and python. I'm trying to write a correlation block,
somewhere in my code I use fft filter:
gr::filter::kernel::fft_filter_ccc *d_filter;
d_filter = new gr::filter::kernel::fft_filter_ccc(1, x_vector);
d_filter->filter(noutput_items,in_y,out);
I run
cmake ../
make
and it complies perfectly fine,
but when i try
make test
I'll get this error:
Traceback (most recent call last):
2: File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/python/qa_fd_correlation_cc.py", line 25, in <module>
2: import full_duplex_swig as full_duplex
2: File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/swig/full_duplex_swig.py", line 28, in <module>
2: _full_duplex_swig = swig_import_helper()
2: File "/home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/swig/full_duplex_swig.py", line 24, in swig_import_helper
2: _mod = imp.load_module('_full_duplex_swig', fp, pathname, description)
2: ImportError: /home/mohammad/projects/FD/implementation_tests/oot_modules/gr-full_duplex/build/lib/libgnuradio-full_duplex.so: undefined symbol: _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
1/1 Test #2: qa_fd_correlation_cc .............***Failed 1.30 sec
This often happens when you have declared a method at the header file, but you do not implement it. For example a destructor or something else.
To find out which method it is you should demangle the undefined symbol _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi.
This can be done using the c++filt tool. For example,
c++filt \ _ZN2gr6filter6kernel14fft_filter_cccC1EiRKSt6vectorISt7complexIfESaIS5_EEi
In your case this symbol is an existing symbol of the GNU Radio, located in the gr-filter module. Each GNU Radio module creates a library, so in order to resolve the undefined symbol issue you have to link against the required library. To accomplish this you have to do the following steps:
At the CMakeLists.txt file of your module, specify on which components of GNU Radio you depend. In your case the FILTER component.
set(GR_REQUIRED_COMPONENTS RUNTIME FILTER)
find_package(Gnuradio "3.7.0" REQUIRED)
Further dependencies can be inserted, eg:
set(GR_REQUIRED_COMPONENTS RUNTIME FILTER DIGITAL)
After that you can use the ${GNURADIO_ALL_INCLUDE_DIRS} and ${GNURADIO_ALL_LIBRARIES} auto generated variables to properly include the proper header files and link against the appropriate libraries.
E.g:
include_directories(
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/lib
${CMAKE_BINARY_DIR}/include
${Boost_INCLUDE_DIRS}
${CPPUNIT_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${GNURADIO_ALL_INCLUDE_DIRS}
)
target_link_libraries(gnuradio-howto
${Boost_LIBRARIES}
${GNURADIO_RUNTIME_LIBRARIES}
${GNURADIO_ALL_LIBRARIES})
For more info refer here.
Update to answer by #manos:
As of GNU Radio 3.8+ the CMakeList.txt files have slightly changed.
The line one needs to change in the toplevel CMakeList.txt is:
find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks analog filter fft)
And in lib/CMakeList.txt:
target_link_libraries(gnuradio-tempest gnuradio::gnuradio-runtime gnuradio::gnuradio-blocks gnuradio::gnuradio-fft gnuradio::gnuradio-filter Volk::volk)
Source: https://wiki.gnuradio.org/index.php/GNU_Radio_3.8_OOT_Module_Porting_Guide
Related
i'm trying to install pyrouge, and i ran this code (following this repo)
from pyrouge import Rouge155
from pprint import pprint
ref_texts = {'A': "Poor nations pressurise developed countries into granting trade subsidies.",
'B': "Developed countries should be pressurized. Business exemptions to poor nations.",
'C': "World's poor decide to urge developed nations for business concessions."}
summary_text = "Poor nations demand trade subsidies from developed nations."
rouge = Rouge155(n_words=100)
score = rouge.score_summary(summary_text, ref_texts)
pprint(score)
But i got some error, the traceback displayed as below:
Traceback (most recent call last):
File "<ipython-input-116-94aea372ee05>", line 1, in <module>
runfile('C:/Users/cerdas/Documents/Bil/Lat/rouge.py', wdir='C:/Users/cerdas/Documents/Bil/Lat')
File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/cerdas/Documents/Bil/Lat/rouge.py", line 10, in <module>
rouge = Rouge155(n_words=100)
TypeError: __init__() got an unexpected keyword argument 'n_words'
and here the code of __init__.py
from pyrouge.base import Doc, Sent
from pyrouge.rouge import Rouge155
and the called function Rouge155
class Rouge155(object):
def __init__(self, rouge_home=ROUGE_EVAL_HOME, n_words=None, stem=False, keep_files=False):
self._stem = stem
self._n_words = n_words
self._discover_rouge(rouge_home)
self._keep_files = keep_files
You need to export your environment variable: ROUGE_EVAL_HOME
From the docs:
Assuming a working ROUGE-1.5.5. installation, tell pyrouge the ROUGE path with this command:
pyrouge_set_rouge_path /absolute/path/to/ROUGE-1.5.5/directory
Go to your Repository (Your folder where you cloned this from). Now make your way into pyrouge/base.py and make sure the variable ROUGE_EVAL_HOME points to tools/ROUGE-1.5.5.Try entering the entire destination manually by copying the filepath and then if it works try using os module to make it more dynamic. You need to tell your code to point to the ROUGE package that is in your repository not the one you get from pip install pyrouge
The following instructions were tested on Windows 10 and python 3.7x32
Do download your project pyrouge on the repository of the
Anders Johannsen. No install thought for pip install pyrouge.
To solve I had to make a small modification at the moment the command line is built that and will run ROUGE-1.5.5.pl. In windows, besides you need to add PERL.exe to the environment variables, but you will also need change the class Rouge155() in file code \pyrouge\rouge.py.
Open the file code \pyrouge\rouge.py go to the function def _run_rouge(self) (it's at line 96 at the time I am writing this answer).
Go to the line 122, comment this line return check_output([self._rouge_bin] + options)
Add this code in place:
command = [self._rouge_bin] + options
command.insert(0, 'perl ')
return check_output(command)
Franck Dernoncourt in your answer for the question How to install the Python package pyrouge on Microsoft Windows? solved the problem in the step 7, but this step only works in pyrouge installed through of the pip install rouge, in the implementation of repository of the other author, Benjamin Heinzerling.
And you are trying to use the version available the repository of the author Anders Johannsen. The his implementation has the class with the arguments you commented n_words=100, but only in the his version of the class Rouge155(), and her not in Python Package Index (PyPI).
P.S: Sorry for any mistake, my english is medium.
I am porting CPython to Emscripten, and it builds successfully. However, when I try to run the python.asm.js through Node.js, I get a very strange error inside the Py_InitializeEx(0) call:
Traceback (most recent call last):
File "/lib/python2.7/site.py", line 62, in <module>
import os
File "/lib/python2.7/os.py", line 44, in <module>
from posix import *
TypeError: 'NotImplementedType' object does not support indexing
The error is generated from PySequence_GetItem in Objects/abstract.c, but I don't understand how the execution gets there. If I do import posix before the line that causes the error, the import posix statement finish successfully, and I can call functions in the posix module. Thus, the error is related to from <module> import * line. How is PySequence_GetItem related to from <module> import * statement, and what could be the reasons for the error?
If you want to reproduce the problem, I released the code on GitHub
While investigating what is going wrong, I switched off the optimization (compiled and linked with -O0). The resulting JS executable also failed, but with a different error:
Invalid function pointer '495' called with signature 'iii'. Perhaps this is
an invalid value (e.g. caused by calling a virtual method on a NULL pointer)?
Or calling a function with an incorrect type, which will fail? (it is worth
building your source files with -Werror (warnings are errors), as warnings can
indicate undefined behavior which can cause this)
This pointer might make sense in another type signature:
ii: _dict_keys iiii: 0 i: undefined iiiii: 0 viii: 0 vii: 0 vi: 0 v: 0
495
495
I looked through Emscripten's settings.js for options related to function pointers, and found EMULATE_FUNCTION_POINTER_CASTS which fixed the problem.
Installed julia v0.3.2 into MacOSX 10.9.5
Did
Pkg.add("IJulia")
Pkg.add("PyPlot")
initiate ijulia with:
ipython notebook --profile=julia
This starts an IJulia notebook (it says IJ in the top left.
I enter using pyplot into the first line of iJulia, hit shift enter, and get this:
objc[21233]: Class TKApplication is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[21233]: Class TKMenu is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[21233]: Class TKContentView is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[21233]: Class TKWindow is implemented in both /Library/Frameworks/Tk.framework/Versions/8.5/Tk and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
INFO: Loading help data...
Warning: requiring "pyplot" did not define a corresponding module.
OK, so my mac has the tk package installed in two places. If i remove the TK and TCL frameworks from Library/Frameworks, as suggested here:
http://michaelwelburn.com/2013/06/07/python-error-conflicting-tk-libraries-and-activetcl/
and here:
Python tk framework
then I get the following error when I try to start iJulia:
INFO: Loading help data...
Warning: requiring "pyplot" did not define a corresponding module.
The other authors said this worked so I am confused.
My /usr/local/bin directory includes these) executables:
tclselect tclsh tclsh8.5 tclsh8.6 tclvfse wish wish8.5 wish8.6
I hesitate to remove the system framework. I have the native mac python as well as the anaconda version (which has its own lib/tk) I am at a loss as to the next step.
EDIT: My julia code is this:
using PyPlot
# julia set
# (the familiar mandelbrot set is obtained by setting c==z initially)
function julia(z, c; maxiter=200)
for n = 1:maxiter
if abs2(z) > 4
return n-1
end
z = z*z + c
end
return maxiter
end
# varying the second argument to julia() tiny amounts results in a stunning variety of forms
#time m = [ uint8(julia(complex(r,i), complex(-.06,.67))) for i=1:-.002:-1, r=-1.5:.002:1.5 ];
# the notebook is able to display ColorMaps
get_cmap("RdGy")
imshow(m, cmap="RdGy", extent=[-1.5,1.5,-1,1])
each line executes fine in iJulia except the last line starting with imshow which gives this error:
PyError (PyObject_Call) <class '_tkinter.TclError'>
TclError('Can\'t find a usable tk.tcl in the following directories: \n /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts\n\n/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl: version conflict for package "Tk": have 8.5.15, need exactly 8.5.9\nversion conflict for package "Tk": have 8.5.15, need exactly 8.5.9\n while executing\n"package require -exact Tk 8.5.9"\n (file "/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl" line 20)\n invoked from within\n"source /System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts/tk.tcl"\n ("uplevel" body line 1)\n invoked from within\n"uplevel #0 [list source $file]"\n\n\nThis probably means that tk wasn\'t installed properly.\n',)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 2370, in imshow
ax = gca()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 701, in gca
ax = gcf().gca(**kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py", line 343, in figure
**kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
window = Tk.Tk()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1764, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
while loading In[7], in expression starting on line 1
in pyerr_check at /Users/userme/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /Users/userme/.julia/v0.3/PyCall/src/PyCall.jl:85
in imshow at /Users/userme/.julia/v0.3/PyPlot/src/PyPlot.jl:370
I feel so stupid. My problem was the .bash_profile I had these lines
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
leftover from a previous python install. I also had a bunch of executables in my /usr/local/bin folder from this old python install. When I deleted the python 2.7 folder before putting in anaconda, I forgot to delete these.
Now the error is gone. I hope this helps someone.
For the Warning:
Warning: requiring "*" did not define a corresponding module.
In some cases it helps to check if we use a stable version.
Ran into same issues with 0.38+pre-versions.
After switching back to 0.37 stable the issue was gone.
Run into this issue with PyCall:
Warning: requiring "PyCall" did not define a corresponding module.
I read in the howto documentation to install Trigger, but when I test in python environment, I get the error below:
>>> from trigger.netdevices import NetDevices
>>> nd = NetDevices()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 913, in __init__
with_acls=with_acls)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 767, in __init__
production_only=production_only, with_acls=with_acls)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 83, in _populate
# device_data = _munge_source_data(data_source=data_source)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 73, in _munge_source_data
# return loader.load_metadata(path, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/loader.py", line 163, in load_metadata
raise RuntimeError('No data loaders succeeded. Tried: %r' % tried)
RuntimeError: No data loaders succeeded. Tried: [<trigger.netdevices.loaders.filesystem.XMLLoader object at 0x7f550a1ed350>, <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x7f550a1ed210>, <trigger.netdevices.loaders.filesystem.SQLiteLoader object at 0x7f550a1ed250>, <trigger.netdevices.loaders.filesystem.CSVLoader object at 0x7f550a1ed290>, <trigger.netdevices.loaders.filesystem.RancidLoader object at 0x7f550a1ed550>]
Does anyone have some idea how to fix it?
The NetDevices constructor is apparently trying to find a "metadata source" that isn't there.
Firstly, you need to define the metadata. Second, your code should handle the exception where none is found.
I'm the lead developer of Trigger. Check out the the doc Working with NetDevices. It is probably what you were missing. We've done some work recently to improve the quality of the setup/install docs, and I hope that this is more clear now!
If you want to get started super quickly, you can feed Trigger a CSV-formatted NetDevices file, like so:
test1-abc.net.example.com,juniper
test2-abc.net.example.com,cisco
Just put that in a file, e.g. /tmp/netdevices.csv and then set the NETDEVICES_SOURCE environment variable:
export NETDEVICES_SOURCE=/tmp/netdevices.csv
And then fire up python and continue on with your examples and you should be good to go!
I found that the default of /etc/trigger/netdevices.xml wasn't listed in the setup instructions. It did indicate to copy from the trigger source folder:
cp conf/netdevices.json /etc/trigger/netdevices.json
But, I didn't see how to specify this instead of the default NETDEVICES_SOURCE on the installation page. But, as soon as I had a file that NETDEVICES_SOURCE pointed to in my /etc/trigger folder, it worked.
I recommend this to get the verifying functionality examples to work right away with minimal fuss:
cp conf/netdevices.xml /etc/trigger/netdevices.xml
Using Ubuntu 14.04 with Python 2.7.3
I've been trying to build pHash(http://phash.org/) on my windows machine and haven't been having any luck. I'm new to programming desktop applications. I will be using the pHash library with Python through ctypes. Could someone post the steps involved with building pHash?
What I tried, was opening pHash.sln with Visual Studio 2008 and chooing the Release(as opposed to debug) and building pHash. I wasn't sure where it was building to as I couldn't find the file. I tried looking in Visual Studio's projects folder but it wasn't there so I assumed it was building to pHash/release/pHash.dll, but when I load that dll with ctypes.cdll none of the functions listed in the pHash docs(http://phash.org/docs/howto.html) seem to be accessible, e.g. ph_dct_imagehash(), ph_dct_videohash.
Here is an example of my code:
import ctypes
import inspect
PHASHPATH = "C:\Users\me\Downloads\phash\release\pHash.dll"
phash_dll = ctypes.CDLL(PHASHPATH)
phash_dll['ph_dct_imagehash']
The response I get is:
Traceback (most recent call last):
File "C:\Users\me\workspace\project\src\opencv.py", line 12, in <module>
phash_dll['ph_dct_imagehash']
File "C:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'ph_dct_imagehash' not found
I'm new at this, so please bear with me. Thanks.
EDIT:
I'm running Python 2.7.
Except for some dirent functions, no pHash functions are exported from pHash.dll. That can be verified with DependencyWalker http://www.dependencywalker.com/. Try adding __declspec(dllexport) in front of the function declarations in pHash.h (e.g. for ph_dct_imagehash) and recompile.