I compiled my Python code with Cython and got a .pyd
file. I want to import it so I was advised to put it in my PYTHONPATH
.
Here it is :
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\spyder\\utils\\site',
'C:\\Users\\loic\\Anaconda2\\python27.zip',
'C:\\Users\\loic\\Anaconda2\\DLLs',
'C:\\Users\\loic\\Anaconda2\\lib',
'C:\\Users\\loic\\Anaconda2\\lib\\plat-win',
'C:\\Users\\loic\\Anaconda2\\lib\\lib-tk',
'C:\\Users\\loic\\Anaconda2',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\Sphinx-1.5.1-py2.7.egg',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\win32',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\win32\\lib',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\Pythonwin',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\setuptools-27.2.0-py2.7.egg',
'C:\\Users\\loic\\Anaconda2\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\loic\\.ipython']
I put my .pyd
file in C:\\Users\\loic\\Anaconda2\\lib\\site-packages
and when I tried to import it with Python I got that message:
import maido
ImportError: DLL load failed: %1 is not a valid Win32 application.
Then I put my .pyd
file in the same directory as my Python programm and I got the exact same message.
I did some research and I came across that post (Using cython extension once compiled [under Windows], how to use .pyd's?) but it doesn't seem to give me more information.
I am using Python 64 bits with Anaconda 2 because the code I compiled required Python 64 bits (it needed more memory because otherwise the console was quickly saturated in memory).
Can someone tell me what should I do to make it work with Python 64 bits please ?
EDIT: In case you need it, here is my setup.py
file
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy as np
setup(name = "maido",
include_dirs = [np.get_include()],
cmdclass = {'build_ext': build_ext},
ext_modules = cythonize("C:\Users\python\Documents\maido\maido_cython.pyx"),
)