Python cprofile compilation error

using cProfile python I have cprofiled my code, but I keep getting this compiler () and null related error which I cannot figure out.

Error message:

[cProfileV]: cProfile output is available at http://127.0.0.1:4000 Traceback (last call last): File "/Library/Frameworks/Python.framework/Versions/2.7/bin/cprofilev", line 9, at load_entry_point ( 'CProfileV == 1.0.6', 'console_scripts', 'cprofilev') () File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cprofilev.py", line 217, in main code = compile (fp.read (), progname, 'exec') TypeError: compile () expected string without null bytes

Is this a problem with my client code, or is the server just not working?

Thanks in advance.

+3


source to share


2 answers


I believe the error is caused by a mismatch between the cprofile and cprofilev versions.

Cprofilev can be run directly using:



python -m cprofilev your_script.py

+3


source


This has been asked before.



Anyway, the error means you are getting a string that you cannot read well because it contains null. This means the server is getting up and responding, but you cannot read the response correctly. This is because it is in a different format, which is most likely JSON. try using the JSON module included in python 2.6 and up; you can see some examples for this here. If you provide us with your code, I can help you convert your app to JSON - another one. :)

0


source







All Articles