matplotnode icon indicating copy to clipboard operation
matplotnode copied to clipboard

Could not import matplotlib.pyplot

Open metbosch opened this issue 9 years ago • 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?

metbosch avatar May 23 '17 09:05 metbosch

Same. Did you resolve it?

ZephD avatar May 30 '18 15:05 ZephD

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

metbosch avatar May 31 '18 15:05 metbosch

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.

bpopnikolov avatar Dec 26 '18 09:12 bpopnikolov

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

mateogianolio avatar Mar 07 '19 21:03 mateogianolio

Running into this right now with 0.3.0. Running on OSX

squarewave avatar Apr 03 '19 18:04 squarewave

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?

mateogianolio avatar Apr 03 '19 21:04 mateogianolio

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

mateogianolio avatar Apr 03 '19 22:04 mateogianolio

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.

squarewave avatar Apr 04 '19 16:04 squarewave

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

squarewave avatar Apr 04 '19 16:04 squarewave

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.

mateogianolio avatar Apr 04 '19 17:04 mateogianolio

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

mateogianolio avatar Apr 04 '19 17:04 mateogianolio

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

mateogianolio avatar Apr 04 '19 17:04 mateogianolio

Hooray! Works for me as well now.

squarewave avatar Apr 04 '19 18:04 squarewave

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

mateogianolio avatar Apr 04 '19 18:04 mateogianolio