mateogianolio/matplotnode

Could not import matplotlib.pyplot

Closed this issue · 14 comments

I'm trying to use the module but I'm not able to make it work.
I get the following error when run the first module call:

me@computer:~/test$ node
> const plt = require('matplotnode');
undefined
> plt.plot([0,1], [5.5,6.5]);
Could not import matplotlib.pyplot.
Segmentation fault (core dumped)

I think that python and matplotlib are well installed. When I run the following code a new window appear with the plot:

me@computer:~/test$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([0,1], [5.5,6.5])
[<matplotlib.lines.Line2D object at 0x7fad157bac50>]
>>> plt.show()

I'm running on Ubuntu 16.04. Have you any idea about what I'm doing wrong?

ZephD commented

Same. Did you resolve it?

@ZephD No, I just switched the scripts to python :(

Any news about this issue? I've made sure that python 2.7 is installed and I have matplotlib package too but I still get Could not import matplotlib.pyplot. Segmentation fault (core dumped) error when trying to run the package in node.

Try with the version I just released. I think I fixed some issues.

Running into this right now with 0.3.0. Running on OSX

Hmm,

  • Have you installed matplotlib with pip (run pip list | grep matplotlib) and which version is it?
  • Which version of python are you using on OS X (python --version)? I'm using the built-in python 2.7.10 and it works for me.
  • Could you run node test.js after install and see if it runs without segmentation fault?

I just tried the following without issues in a completely empty folder on my computer (MacOS 10.14.3). I am confused as to what is causing this issue for you.

npm install matplotnode
node
> const plt = require('matplotnode');
undefined
> plt.plot([0, 1], [5, 6]);
undefined
> plt.show();
undefined
> .exit

I'm on MacOS 10.14.3, matplotlib is version 2.2.4, python is 2.7.15

mkdir test
cd test
npm install matplotnode
node

const plt = require('matplotnode');
undefined
plt.plot([0, 1], [5, 6]);
Could not import matplotlib.pyplot.
[1] 63191 segmentation fault node

I will see if I can get anywhere with this on my end if I have some time in the near future.

(To clarify, node test.js after install also fails in the same way)

Wow I was using 1.3.1... I think I found the bug (had to call matplotlib.use("TkAgg")). It works for me now on matplotlib 2.2.4.

Also added some PyErr_Print()s that will hopefully provide clearer error messages.

There might still be memory leaks, since I'm kind of clueless about how the Python reference counting works.

Hooray! Works for me as well now.

Closing this, please open a new issue if you encounter this again!