is there a way to embed python 3.7 code in D program?

evilrat evilrat666 at gmail.com
Tue May 14 02:22:26 UTC 2019


On Monday, 13 May 2019 at 21:29:18 UTC, Danny Arends wrote:
>
> "ImportError: No module named 'stuff'"
>
> How do I make the py_import file from pyd find the stuff.py 
> file ?
>

On Linux PYTHONPATH doesn't have current directory by default, so 
a hacky way to do it is to add it to PYTHONPATH prior to each run

     PYTHONPATH=. ./prog

More realistic solution of course is to add it before importing 
anything in your code

     void main()
     {
         py_stmts("import sys; sys.path += './'");
         ...
     }

Or alternatively set the environment variable from D

>
> ps. I removed the vs debugger stuff since I'm on Linux
>

It is cross platform, I just tested it myself and it works fine. 
You can mixed debugging D and Python is VS Code even on Linux.


More information about the Digitalmars-d-learn mailing list