koji-kojiro / matplotlib-d

MIT License
10 stars 6 forks source link

Crashes on plt.show() #14

Open fccoelho opened 5 years ago

fccoelho commented 5 years ago

object.Exception@/home/fccoelho/.dub/packages/matplotlib-d-0.1.5/matplotlib-d/source/matplotlibd/core/pycall.d(20):

ERROR occurred in Python: Traceback (most recent call last): File "", line 2, in NameError: name 'inf' is not defined


/home/fccoelho/.dub/packages/matplotlib-d-0.1.5/matplotlib-d/source/matplotlibd/core/pycall.d:20 void matplotlibd.core.pycall.call(immutable(char)[]) [0x563d2a7c6c31] /home/fccoelho/.dub/packages/matplotlib-d-0.1.5/matplotlib-d/source/matplotlibd/pyplot.d-mixin-41:378 void matplotlibd.pyplot.show!().show() [0x563d2a7c517b]

andre2007 commented 5 years ago

@fccoelho

When you directly write a python script with the mentioned command, does it work or the same error occur?

fccoelho commented 5 years ago

Ubuntu Python 3.6 Matplotlib 3.x(latest from pypi)

I use python + matplotlib every day without issues .

Em qua, 3 de jul de 2019 16:12, andre2007 notifications@github.com escreveu:

@fccoelho https://github.com/fccoelho

  • which operation system?
  • which python version?
  • which matplotlib version?

When you directly write a python script with the mentioned command, does it work or the same error occur?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koji-kojiro/matplotlib-d/issues/14?email_source=notifications&email_token=AABCGWYNBHOJRMH4CMABKBDP5T2YDA5CNFSM4H5IV732YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFNOGY#issuecomment-508221211, or mute the thread https://github.com/notifications/unsubscribe-auth/AABCGW3IT7UB5EQ4OMOQWGDP5T2YDANCNFSM4H5IV73Q .

andre2007 commented 5 years ago

While this dub library is built, it executes this python script https://github.com/koji-kojiro/matplotlib-d/blob/master/python/prebuild.py. The python script generates this file on your local pc https://github.com/koji-kojiro/matplotlib-d/blob/master/views/pyplot_functions.txt.

The python script was written for python 2 and fails for python 3 (it is already fixed on master but not released to code.dlang.org).

I am also not sure wheter on your system python 2 or python 3 is used to call this script. Is python mapped to 2 or 3 on your system?

andre2007 commented 5 years ago

@koji-kojiro could you please create a new release to get the latest changes from master? Maybe it would also be a good idea to add to the python script a log containing the python version and the matplotlib version. This would make error investigation a lot easier.

fccoelho commented 5 years ago

I am also not sure wheter on your system python 2 or python 3 is used to call this script. Is python mapped to 2 or 3 on your system?

Yes, you nailed it. in my system, python points to python2.7 so the shebang line on the prebuild.py module should be `#!/usr/bin/env python3

andre2007 commented 5 years ago

I am not a linux/python expert, is python3 always correct or are there systems where python points to version 3 and an executable python3 does not exist?

fccoelho commented 5 years ago

Well, yes you are correct. Changing the shebang line to python3 would fail on some machine where the only python installed is three and referenced simply as python.

On the other hand, I tried to run my d program from a virtualenv where python meant only python 3.6 but I got the same error. I should say that I have matplotlib installed also for python2.7 on my system and I can plot normally from the python2.7 console.

fccoelho commented 5 years ago

Again if we look at the exception thrown by python in this case, is:

Traceback (most recent call last):
File "", line 2, in
NameError: name 'inf' is not defined

So it seems to be related to the code being generated by matplotlib-d which is not defining inf. logging the full traceback from python would help to debug this issue.

fccoelho commented 5 years ago

Ok, I have found the issue. My problem is that one of the series I am plotting includes an inf value... That's why the plot is failing. I think it would be a good Idea to convert the data to python compatible types.