Thread overview
Python and D (PyD)
Nov 29, 2017
Fat_Umpalumpa
Nov 29, 2017
Nicholas Wilson
Nov 29, 2017
Fat_Umpalumpa
Dec 05, 2017
Fat_Umpalumpa
November 29, 2017
Hello, I have searched these forums a bit to see if it is possible to use python libraries such as matplotlib which I have enough experience with, and wish to continue using this wonderful library within D. Maybe there are great D graphing libraries, but I have zero experience with them.

I cam across PyD and found an example from "Welcome to Quick Start with D!"
http://d.readthedocs.io/en/latest/examples.html#plotting-with-matplotlib-python

I have tried to understand the example here and thoroughly as possible, to the point of downloading the Github example https://github.com/andralex/thenextafterc/tree/master/examples/matplotlib

When I try to compile the app.d script with dmd I get the following error

app.d(1): Error: module pyd is in file 'pyd/pyd.d' which cannot be read
import path[0] = /Library/D/dmd/src/phobos
import path[1] = /Library/D/dmd/src/druntime/import

I have tried to install PyD with pip and installed version 0.10 which I think is the same as
https://pypi.python.org/pypi/pyd

But according to dlang https://code.dlang.org/packages/pyd only up to version 0.9.9 is supported?
November 29, 2017
On Wednesday, 29 November 2017 at 06:34:53 UTC, Fat_Umpalumpa wrote:
> Hello, I have searched these forums a bit to see if it is possible to use python libraries such as matplotlib which I have enough experience with, and wish to continue using this wonderful library within D. Maybe there are great D graphing libraries, but I have zero experience with them.
>
> I cam across PyD and found an example from "Welcome to Quick Start with D!"
> http://d.readthedocs.io/en/latest/examples.html#plotting-with-matplotlib-python
>
> I have tried to understand the example here and thoroughly as possible, to the point of downloading the Github example https://github.com/andralex/thenextafterc/tree/master/examples/matplotlib
>
> When I try to compile the app.d script with dmd I get the following error
>
> app.d(1): Error: module pyd is in file 'pyd/pyd.d' which cannot be read
> import path[0] = /Library/D/dmd/src/phobos
> import path[1] = /Library/D/dmd/src/druntime/import
>
> I have tried to install PyD with pip and installed version 0.10 which I think is the same as
> https://pypi.python.org/pypi/pyd
>
> But according to dlang https://code.dlang.org/packages/pyd only up to version 0.9.9 is supported?

you need to tell the compiler where to look to find pyd (which it can't find in '/Library/D/dmd/src/phobos' or '/Library/D/dmd/src/druntime/import').
If you are invoking the compiler yourself use the `-I` switch (`-Ipath/to/pyd`).
Or if you are using dub (I recommend this) make sure that is is in your list of dependencies.
November 29, 2017
> you need to tell the compiler where to look to find pyd (which it can't find in '/Library/D/dmd/src/phobos' or '/Library/D/dmd/src/druntime/import').
> If you are invoking the compiler yourself use the `-I` switch (`-Ipath/to/pyd`).
> Or if you are using dub (I recommend this) make sure that is is in your list of dependencies.

Ahhh thank you! I'm still new to the d language and dub worked fine.


December 05, 2017
Omg this was working a few days ago just fine! Now I can't even start the histogram example! I haven't changed the code and I know this worked a week ago.

dub still builds the program, however now when running the program, I get an error

object.Exception@../../../.dub/packages/pyd-0.9.9/pyd/infrastructure/pyd/extra.d(74): numpy is not available

and then many more errors as if I have a problem with python or numpy... Crap I was installing random things with pip and may have ruined something.

I'll post a few more errors but I think the problem is on line (74) of the extra.d script

4   matplot_d                           0x000000010c2f5262 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) + 126
5   matplot_d                           0x000000010c2f51d6 pure @safe deimos.python.object.PyTypeObject* std.exception.enforce!(Exception, deimos.python.object.PyTypeObject*).enforce(deimos.python.object.PyTypeObject*, lazy const(char)[], immutable(char)[], ulong) + 106
6   matplot_d                           0x000000010c31065a deimos.python.object.PyObject* pyd.extra.d_to_python_numpy_ndarray!(long[]).d_to_python_numpy_ndarray(long[]) + 70
7   matplot_d                           0x000000010c2e8429 _Dmain + 73