Error with matplotlib

Samir samir at aol.com
Sun Feb 17 20:19:23 UTC 2019


I am trying to run the code from the "Simple Example" listed in 
the matplotlib-d package page[1] and am running into the 
following error:

$ dub build
Performing "debug" build using 
/usr/home/samir/dlang/dmd-2.082.0/freebsd/bin64/dmd for x86_64.
matplotlib-d 0.1.4: building configuration "library"...
Running pre-build commands...
Traceback (most recent call last):
   File 
"/home/samir/.dub/packages/matplotlib-d-0.1.4/matplotlib-d/python/prebuild.py", line 37, in <module>
     gen_pyplot_functions(argv[1])
   File 
"/home/samir/.dub/packages/matplotlib-d-0.1.4/matplotlib-d/python/prebuild.py", line 25, in gen_pyplot_functions
     import matplotlib.pyplot
ImportError: No module named matplotlib.pyplot
Command failed with exit code 1: python 
/home/samir/.dub/packages/matplotlib-d-0.1.4/matplotlib-d/python/prebuild.py /home/samir/.dub/packages/matplotlib-d-0.1.4/matplotlib-d

Some information about my environment:
$ uname -a
FreeBSD enterprise 11.2-RELEASE-p9 FreeBSD 11.2-RELEASE-p9 #0: 
Tue Feb  5 15:30:36 UTC 2019     
root at amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  
amd64
$ dmd --version
DMD64 D Compiler v2.082.0
Copyright (C) 1999-2018 by The D Language Foundation, All Rights 
Reserved written by Walter Bright
$ python3
Python 3.6.7 (default, Jan 10 2019, 01:15:48)
[GCC 4.2.1 Compatible FreeBSD Clang 6.0.0 (tags/RELEASE_600/final 
326565)] on freebsd11
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import matplotlib
>>> matplotlib.__file__
'/usr/local/lib/python3.6/site-packages/matplotlib/__init__.py'
>>> matplotlib.__version__
'3.0.2'

dub.json:
{
     "name": "matplotlib",
     "authors": [
         "User &"
     ],
     "description": "A minimal D application.",
     "copyright": "Copyright _ 2019, User &",
     "license": "proprietary",
     "dependencies": {
         "matplotlib-d": "~>0.1.4"
     }
}

source/app.d:
import std.math;
import std.range;
import std.algorithm;
import plt = matplotlibd.pyplot;

void main() {
  auto x = iota(0, 2.05, 0.05).map!(x => x * PI);
  auto y = x.map!(sin);

  plt.plot(x, y, "r-", ["label": "$y=sin(x)$"]);
  plt.xlim(0, 2 * PI);
  plt.ylim(-1, 1);
  plt.legend();
  plt.savefig("simple.png");
  plt.clear();
}

[1] http://code.dlang.org/packages/matplotlib-d


More information about the Digitalmars-d-learn mailing list