1
$ cythonize -a -i hello.pyx

running build_ext
building 'hello' extension
...

Now I have a hello.so file, as well as the other ones (hello.pyx, hello.c)

When I then try to import the function:

$ python
Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar  6 2017, 11:58:13) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_hello)
>>> 

I know this has been asked before (link below), but it seems the solution was to run python3, which I am doing already, so I don't know how to fix my problem Cython Compilation Error: dynamic module does not define module export function

I should add the cythonize version I am using: $ cython --version Cython version 0.24

pwprnt
  • 521
  • 3
  • 9
  • 27
  • 2
    Possible that `cythonize` is pointing to a python 2 install? Check the output of `$ which cythonize` – chrisb Feb 09 '18 at 21:52
  • thanks but I don't really understand how to check completely. I am using my local machine as logged into a remote server. I did which cythonize and got: ~/.conda/envs/mypython/bin/cythonize . I tried also updating the cython by doing conda install cython package | build ---------------------------|----------------- cython-0.26 | py35_0 7.0 MB – pwprnt Feb 09 '18 at 23:28
  • @chrisb , ok I think that isn't the problem because it is pointing to a python 3 install: $ head `which cythonize` #!/u1/usr/.conda/envs/mypython/bin/python if _name_ == '_main_': import sys import Cython.Build.Cythonize sys.exit(Cython.Build.Cythonize.main()) (mypython) remoteserver01 $ /u1/usr/.conda/envs/mypython/bin/python --version Python 3.5.3 :: Continuum Analytics, Inc. – pwprnt Feb 10 '18 at 00:14
  • When the extension is built, it logs the build commands. Does it take python3 or python2 libraries? – ead Feb 10 '18 at 07:12
  • Have a look at the output of `objdump -T hello.something.so`. You're interested in function names with `init` or `Init` in. This might give you an idea what has happened (edit the `something` to match your file!) – DavidW Feb 10 '18 at 15:20

0 Answers0