0

I'm currently trying to cythonize a part of my python code, I have a file called setupcython.py which is:

from distutils.core import setup, Extension
from Cython.Distutils import build_ext
import numpy.distutils.misc_util
include_dirs = numpy.distutils.misc_util.get_numpy_include_dirs()
setup(name='clib',
version='1.0',
ext_modules=[Extension('clib', ['clib.pyx'], include_dirs=include_dirs, extra_compile_args=["-O3"])],
  cmdclass={'build_ext' : build_ext}
  )`

So I run setupcython.py build_ext --inplace Once it completed, I got :

running build_ext
skipping 'clib.c' Cython extension (up-to-date)
building 'clib' extension

And a clib.c file is created in my folder

But then when I try to import clib in my other code it says

File "<ipython-input-27-aa10750d0f61>", line 1, in <module>
runfile('C:/Users/FAB/Desktop/code python/CPM-1celltype.py',     wdir='C:/Users/FAB/Desktop/code python')
File "C:\ProgramData\Anaconda2\lib\site- packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/FAB/Desktop/code python/CPM-1celltype.py", line 13, in <module>
import clib
ImportError: No module named clib

However I made sure I was in the proper folder so I don't know what could be wrong, do you have an idea?

Thank you

KungFury
  • 23
  • 5
  • 1
    It is not the `.c` file that you need to import but the `.pyd` file. This one might be somewhere deeply in a directory named `build`. – MB-F Mar 30 '17 at 07:57
  • Thanks for your reply, but I can't find any clib.pyd file in directory named build neither in any folder :( – KungFury Mar 30 '17 at 17:11
  • It certainly should be there if the build succeeded. You don't get any error messages, do you? Is there maybe a `.dll`? In that case try renaming it to `.pyd`. – MB-F Mar 30 '17 at 18:19
  • I type : run setupcython.py build_ext --inplace and I got running build_ext skipping 'clib.c' Cython extension (up-to-date) building 'clib' extension – KungFury Mar 31 '17 at 08:41
  • There is no .dll either – KungFury Mar 31 '17 at 08:42
  • Can you copy-paste the output of `ls -lh` in your project's working directory? That would be the place where the setup file is found – Pierre de Buyl Mar 31 '17 at 10:52
  • Le volume dans le lecteur C n'a pas de nom. Le num‚ro de s‚rie du volume est 18D3-8D84 R‚pertoire de C:\Users\FAB\Desktop\code python Fichier introuvable – KungFury Apr 01 '17 at 13:21

0 Answers0