rust-python-example icon indicating copy to clipboard operation
rust-python-example copied to clipboard

Does not work on Windows OS

Open pydemo opened this issue 4 years ago • 4 comments

import os
import sys
from ctypes import *

lib = cdll.LoadLibrary(r'myrustlib.dll')
val='tesTTanotheRRtesTTtest'
lib.count_doubles(val)

errors out:


    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'count_doubles' not found

pydemo avatar Mar 10 '20 01:03 pydemo

just rename myrustlib.dll to myrustlib.pyd and import should work by name.

szabolcsdombi avatar Sep 09 '20 15:09 szabolcsdombi

just rename myrustlib.dll to myrustlib.pyd and import should work by name.

Can you paste your code here? I also get the same error result. Thanks.

bindy avatar Sep 14 '20 07:09 bindy

pyd files can be imported by name

>>> import myrustlib
>>> dir(myrustlib)
[...]

make sure myrustlib is on pythonpath, if not just put it next the the py file that imports it.

szabolcsdombi avatar Sep 15 '20 14:09 szabolcsdombi

move myrustlib.pyd to the project's root in this case. the Makefile does this for the .so file on linux. On windows the the so equivalent is dll but it must be renamed to pyd.

szabolcsdombi avatar Sep 15 '20 14:09 szabolcsdombi