python36.dll找不到_python cdll找不到模块

当尝试将Python库中包含的dll文件移动到子目录时,出现了加载dll模块失败的问题。通过使用ctypes.CDLL并结合os.path进行路径操作,如改变工作目录来定位dll文件,可以解决找不到模块的错误。但这种方法可能不是最佳实践,因为它涉及到工作目录的切换,可能会引起其他问题。
摘要由CSDN通过智能技术生成

I have a library consisting of two dll files and one python wrapper.

I currently have code based on these three files being in the same parent directory as my main python file. I am now attempting to refactor things before I continue development and would like to move said library code into it's own lib/ directory. Unfortunately, nothing I've tried helps.

import ctypes

_lib = ctypes.cdll["./my.dll"]

The above code located in the python wrapper file loads the dll perfectly fine in it's original location. I've tried various ways of loading it in the new location such as:

from ctypes import *

import os

path = os.path.dirname(os.path.realpath(__file__))

_lib = ctypes.CDLL(os.path.join(path, 'my.dll'))

However python always throws an exception saying unable to find the module.. I have cop

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值