Search code examples
pythoncpython

How to import a pyd file in a computer with other Python version?


I have some *.pyd files that were created on a computer with Python version 3.7.9. I want to use them on a computer with Python 3.8.8. Is there any way to do this? Furthermore, is there any way to create these *.pyd files (or something similar) so that they are compatible with other Python versions?


Solution

  • *.pyd files are just renamed *.dll files, and as such they must be link-compatible with the python you want to execute them on - normally that means compiled by the same, or similar, compiler version. Normally it's not possible, and if it happens to work you have a fragile and irreproducible system. Why not just run setup.py for the package on the version of Python that you're working with (or work with the Python version you have packages for)?