I'm trying to implement a reactor with a kinetic model which I implemented using scipy. Everything works fine until the solver (fmin_slsqp) trys to display its results by using the print command, which results in the following error message:
TypeError : a bytes-like object is required, not 'str'
which causes the script to stop. I can replicate the problem (DWSIM v6.1u4 & WPy 3.7.7) by simply using the print command and choosing Python.NET as an interpreter.
As a workaround, overloading the print function works locally, but does not carry over to the solver. Another way is to disable the solver output, which causes it to skip the print statements. Both are obviously not ideal solutions.
It's propably a really simple fix, I just can't figure it out - any help would be appreciated!
Best Regards
Linus
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the quick reply! That would propably be possible, but it's still a workaround. As for now, the two workarounds which i mentioned earlier work as well, so the problem is not a showstopper. I just hoped you could help me identify the cause of the problem so I could implement a clean solution.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been trying this as well for a few hours but can't get it to work. It might be possible, but I'm not a python expert by any means. I'll just stick to the workaround for now.
Thanks for your help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel and Forum,
I'm trying to implement a reactor with a kinetic model which I implemented using scipy. Everything works fine until the solver (fmin_slsqp) trys to display its results by using the print command, which results in the following error message:
TypeError : a bytes-like object is required, not 'str'
which causes the script to stop. I can replicate the problem (DWSIM v6.1u4 & WPy 3.7.7) by simply using the print command and choosing Python.NET as an interpreter.
As a workaround, overloading the print function works locally, but does not carry over to the solver. Another way is to disable the solver output, which causes it to skip the print statements. Both are obviously not ideal solutions.
It's propably a really simple fix, I just can't figure it out - any help would be appreciated!
Best Regards
Linus
perhaps you could try modifying the print() call directly in the solver code, is that possible?
Thanks for the quick reply! That would propably be possible, but it's still a workaround. As for now, the two workarounds which i mentioned earlier work as well, so the problem is not a showstopper. I just hoped you could help me identify the cause of the problem so I could implement a clean solution.
Actually I also face this issue very often. Perhaps it is something withe Python.NET library. I'll take a look.
Glad to know I'm not the only one. Thanks for looking into it!
Is your scipy module in the latest version?
Sorry for the late reply, I've been out of town for the last two weeks. I'm using scipy 1.4.1, which was included in WinPython 3.771.
Is it possible to override the function globally? I have no idea how to fix it since it is not a problem with DWSIM itself...
I've been trying this as well for a few hours but can't get it to work. It might be possible, but I'm not a python expert by any means. I'll just stick to the workaround for now.
Thanks for your help!