embedding Pyd in Windows program
Matt via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 13 02:38:43 PDT 2015
On Friday, 13 March 2015 at 01:40:34 UTC, Ellery Newcomer wrote:
> On 03/11/2015 07:59 PM, Matt wrote:
>>
>> Right, copying site.py into my program's working dir sorts out
>> the
>> missing module error, but I now get a syntax error:
>>
>> file=sys.stderr)
>> ^
>> SyntaxError: invalid syntax
>> Error executing command run: Program exited with code 1
>>
>> I googled this, and apparently it's caused by an older
>> interpreter. The
>> only files I have transferred over are:
>> python3.DLL
>> python3.LIB
>> python34.LIB
>>
>> Does anyone have any idea what I might be doing wrong, or how
>> I can fix
>> this?
>
> I'm guessing your python path is screwed up. In your embedded
> python,
>
> import sys
> print (sys.path)
>
> make sure everything is pointing where it should.
>
> Failing that,
>
> are you using the correct dub configuration? without checking,
> I believe it defaults to python 2.7.
>
> Failing that,
>
> you transferred python3.dll from somewhere to somewhere? I
> believe pyd links to \windows\system32\python3.dll or some
> such. At least, I think that's where those lib files point to.
> not sure. If that is an issue and you want to use your own lib
> files, you will need to generate OMF files from them.
I used the "~>0.9.4" branch in dub, and I'm not sure how to
change "configuration". Do you mean I should be using "~master"
or "~develop"?
as for the transferring the python3.dll, I downloaded and
installed a fresh copy of the latest Python build, version 3.4,
and copied the libraries from there. Even so, I had to add
PYD_PACKAGE_DIR manually to get it to work.
I'm not sure I'm going to be able to run the python snippet you
sent, since my program, which currently opens a window for three
seconds before closing again, doesn't even get that far, and
chokes when I run py_init().
More information about the Digitalmars-d-learn
mailing list