Closed dpieve closed 10 months ago
plot_save
is a utility function that works out-of-the box in original KFR directory.
For it to work from anywhere (for example in KfrTests
directory) a simple setup is required.
Please provide the full error details for the case after moving dspplotting.py (in the text you posted there is no actual error details, only traceback).
@dancazarin oh ok. Here's the full message I get after I copied the dspplotting.py to my project directory.
biquad_notch...Traceback(most recent call last) :
File "E:\cpp\KfrTests\KfrTests\biquad_notch.py", line 138, in <module>
dspplot.plot(data, phaseresp = True, title = 'Four Biquad Notch filters', file = '../svg/biquad_notch.svg')
File "E:\cpp\KfrTests\KfrTests\dspplotting.py", line 231, in plot
plt.savefig(file)
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\pyplot.py", line 1119, in savefig
res = fig.savefig(*args, **kwargs) # type: ignore[func - returns - value]
^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\figure.py", line 3390, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\backend_bases.py", line 2187, in print_figure
result = print_method(
^ ^^^^^^^^^^^^
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\backend_bases.py", line 2043, in <lambda>
print_method = functools.wraps(meth)(lambda * args, **kwargs: meth(
^ ^^^^
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\backends\backend_svg.py", line 1328, in print_svg
with cbook.open_file_cm(filename, "w", encoding = "utf-8") as fh :
^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\cbook.py", line 497, in open_file_cm
fh, opened = to_filehandle(path_or_file, mode, True, encoding)
^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\will\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\cbook.py", line 483, in to_filehandle
fh = open(fname, flag, encoding = encoding)
^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory : '../svg/biquad_notch.svg'
done
I also tried to have my project inside the kfr directory or kfr/examples.
I had kfr/main.cpp and kfr/examples/main.cpp, with and without the dspplotting.py file. It's still not finding the directory '../svg/biquad_notch.svg'
. I don't know how to fix this
Where is your executable file (.exe) located?
Initially they were inside a x64/Debug, but I moved every file inside it to the kfr folder to execute the .exe. Same errors.
x64/Debug
dspplotting.py
to x64/Debug
.svg
directory under x64
directory. x64/Debug
directory.@dancazarin thank you. It works if I follow your instructions. However, is there a way for me to build/run from VS? If I try directly from VS it fails
Visual Studio launches your executable file with the working directory set to the project root.
To support this case dspplotting.py
should be placed in the project root and svg
directory should be created in the parent directory of your project root (your project root and svg directory should be located at the same directory).
So, all this time, I just have to add a svg folder to the project's directory. @dancazarin Thank you so much, it works now.
When I try the example:
I get that
ModuleNotFoundError
'dspplotting':If I copy the
dspplotting.py
file from thekfr\dsplot\
folder to my project's directory, it's where thebiquad_notch.py
is, then I receive the following error:Setup steps:
(1) Clone kfr:
https://github.com/kfrlib/kfr.git
(2) Install python requirements.txt from kfr directory:pip install -r requirements.txt
(3) Create empty C++ project on Visual Studio. (4) Set toolset toLVVM (clang-cl)
(5) Set C++ Language Standard toISO C++20 Standard (/std:c++20)
(6) Add path to kfr:Properties > VC++ Directories > Include Directories > E:\cpp\kfr\include;
-Windows 11 Pro, 22H2. -Python 3.11.5 (it's added to the path) -Visual Studio 17.7.4.
-I have added to Visual Studio the Python development and clang/LVVM tools. -
matplotlib
,numpy
andscipy
are installed. -I also have LLVM win64 17.0.0 installed.In the directory
kfr/dspplot
, I also tried:What am I missing? Any help would be greatly appreciated.