Using python in D
rnd
r_narang at yahoo.com
Fri Jun 7 14:02:41 UTC 2019
On Friday, 7 June 2019 at 10:55:22 UTC, JN wrote:
> On Friday, 7 June 2019 at 05:04:30 UTC, rnd wrote:
>> On Friday, 7 June 2019 at 04:39:14 UTC, rikki cattermole wrote:
>>> On 07/06/2019 3:54 PM, rnd wrote:
>>>>
>>>> How should I 'initialize python' ?
>>>
>>> The example is probably a good place to begin.
>>>
>>> https://github.com/ariovistus/pyd/blob/master/examples/simple_embedded/hello.d
>>
>> Thanks for the link. After putting in missing statements, it
>> started running but reported:
>>
>> exceptions.ImportError: No module named pandas
>>
>> I believe pyd is working on Python2 while I have pandas
>> installed in Python3.
>>
>> How can I specify Python version 3 in pyd?
>
> https://github.com/ariovistus/pyd
>
> "To use with dub, either specify the relevant subConfiguration
> for your python version, or run source pyd_set_env_vars.sh
> <your python> on linux or pyd_set_env_vars.bat <your python> on
> windows to set the relevant environment variables and use the
> env subConfiguration."
I tried following in dub.selections.json file:
{
"fileVersion": 1,
"versions": {
"pyd": "0.10.5"
},
"subConfigurations": {
"pyd": "python35"
}
}
I also tried python3.5 and python3 in place of python35, but
everytime python27 is being used (where pandas is not installed).
The error is:
$ dub run
Performing "debug" build using /usr/bin/dmd for x86_64.
pyd 0.10.5: target for configuration "python27" is up to date.
<<< NOTE VERSON HERE;
rntestpy ~master: building configuration "application"...
Linking...
To force a rebuild of up-to-date targets, run again with --force.
Running ./rntestpy
pyd.exception.PythonException@/home/cardio/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/pydobject.d(59):
exceptions.ImportError: No module named pandas
----------------
/home/cardio/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/exception.d:46 void pyd.exception.handle_exception(immutable(char)[], ulong) [0x56438721e9e8]
/home/cardio/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/pydobject.d:59 pyd.pydobject.PydObject pyd.pydobject.PydObject.__ctor(deimos.python.object.PyObject*) [0x56438721f2e8]
/home/cardio/.dub/packages/pyd-0.10.5/pyd/infrastructure/pyd/embedded.d:54 pyd.pydobject.PydObject pyd.embedded.py_import(immutable(char)[]) [0x56438721e501]
source/main.d:6 _Dmain [0x56438721ded0]
Program exited with code 1
I also tried command "dub run --force" but still the error
persists.
I also tried to give command "source pyd_set_env_vars.sh
/usr/bin/python3" but still it is not working.
Another command which I tried produced following output but still
the problem persisted:
$ python3 pyd_get_env_set_text.py
export PYD_D_VERSION_1=Python_2_4_Or_Later
export PYD_D_VERSION_2=Python_2_5_Or_Later
export PYD_D_VERSION_3=Python_2_6_Or_Later
export PYD_D_VERSION_4=Python_2_7_Or_Later
export PYD_D_VERSION_5=Python_3_0_Or_Later
export PYD_D_VERSION_6=Python_3_1_Or_Later
export PYD_D_VERSION_7=Python_3_2_Or_Later
export PYD_D_VERSION_8=Python_3_3_Or_Later
export PYD_D_VERSION_9=Python_3_4_Or_Later
export PYD_D_VERSION_10=Python_3_5_Or_Later
export PYD_D_VERSION_11=__PYD__DUMMY__
export PYD_D_VERSION_12=__PYD__DUMMY__
export PYD_D_VERSION_13=__PYD__DUMMY__
export PYD_LIBPYTHON_DIR=/usr/lib
export PYD_LIBPYTHON=python3.5m
Where could be the problem and how can it be solved?
More information about the Digitalmars-d-learn
mailing list