V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
wersonliu9527
V2EX  ›  Python

win10 下 ctypes 加载报错问题

  •  
  •   wersonliu9527 · Mar 16, 2020 · 3416 views
    This topic created in 2236 days ago, the information mentioned may be changed or developed.

    8YK7SP.png

    如图 不是有效的 win 32 但是我的 python 解释器 是32位的

    9 replies    2020-03-18 14:02:28 +08:00
    ysc3839
        1
    ysc3839  
       Mar 16, 2020 via Android
    加载的是什么 DLL ?
    12101111
        2
    12101111  
       Mar 16, 2020
    你加载了 64 位或者 Linux 的东西
    wersonliu9527
        3
    wersonliu9527  
    OP
       Mar 16, 2020
    rwalle
        4
    rwalle  
       Mar 16, 2020 via Android
    @wersonliu9527 那的确不是有效的 win32 啊。。。你要加载 windows 下编译的 dll
    wersonliu9527
        5
    wersonliu9527  
    OP
       Mar 17, 2020
    @rwalle ctypes.cdll.LoadLibrary('xxx.so') 这种操作不允许么
    bitdust
        6
    bitdust  
       Mar 17, 2020
    @wersonliu9527 我估计是没人回你了。我回你吧。
    ctypes 加载二进制库的一个先决条件是:这个二进制库可以在这个系统上正常运行。
    比如你的“*.so”文件,明显是个 linux 下的动态库,这个在 windows 上根本就跑不起来,所以你不可能调用成果~
    wersonliu9527
        7
    wersonliu9527  
    OP
       Mar 17, 2020
    @bitdust 好的,谢谢
    roundgis
        8
    roundgis  
       Mar 17, 2020
    @wersonliu9527 .so 这种受限于 os 是无法兼容的
    banxi1988
        9
    banxi1988  
       Mar 18, 2020
    我来补充一下, 就算是在 linux 下直接加载 .so 库很多情况下也是不一定能成功了.
    除非他们跟你使用 Python 是 ABI 兼容的. 简单来说,如果对应库是 C++ 编译的,又没有提供 C 链接的兼容性(或者做了,但是做得不彻底) 也是无法加载成功的.

    总之,链接,动态加载与库, 真是个大问题.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   876 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 22:12 · PVG 06:12 · LAX 15:12 · JFK 18:12
    ♥ Do have faith in what you're doing.