New to Cython. pyximport error

1,092 views
Skip to first unread message

wflynny

unread,
Mar 3, 2010, 4:59:01 PM3/3/10
to cython-users
Hi -

I am new to cython and have run into a problem using pyximport. I am
using Windows XP, 32-bit and python 2.5.

I created a file called hellow.pyx that simply says
print "Hello World".

Then I went into my command prompt and typed the following:
>>> import pyximport; pyximport.install()
>>> import hellow
gcc: and: No such file or directory
gcc: Settings\wflynn/.pyxbld\lib.win32-2.5\hellow.pyd: No such file or
directory
dllwrap: gcc exited with status 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python25\lib\site-packages\cython-0.12.1-py2.5-win32.egg
\pyximport\pyximport.py", line 3
self.pyxbuild_dir)
File "c:\python25\lib\site-packages\cython-0.12.1-py2.5-win32.egg
\pyximport\pyximport.py", line 1
so_path = build_module(name, pyxfilename, pyxbuild_dir)
File "c:\python25\lib\site-packages\cython-0.12.1-py2.5-win32.egg
\pyximport\pyximport.py", line 1
reload_support=pyxargs.reload_support)
File "c:\python25\lib\site-packages\cython-0.12.1-py2.5-win32.egg
\pyximport\pyxbuild.py", line 85
dist.run_commands()
File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands
self.run_command(cmd)
File "C:\Python25\lib\distutils\dist.py", line 994, in run_command
cmd_obj.run()
File "C:\Python25\lib\distutils\command\build_ext.py", line 290, in
run
self.build_extensions()
File "c:\python25\lib\site-packages\cython-0.12.1-py2.5-win32.egg
\Cython\Distutils\build_ext.py",
self.build_extension(ext)
File "C:\Python25\lib\distutils\command\build_ext.py", line 513, in
build_extension
target_lang=language)
File "C:\Python25\lib\distutils\ccompiler.py", line 845, in
link_shared_object
extra_preargs, extra_postargs, build_temp, target_lang)
File "C:\Python25\lib\distutils\cygwinccompiler.py", line 246, in
link
target_lang)
File "C:\Python25\lib\distutils\unixccompiler.py", line 254, in link
raise LinkError, msg
ImportError: Building module failed: ["LinkError: command 'dllwrap'
failed with exit status 1\n"]

I have configured my distutils.cfg file to read:

[build]
compiler=mingw32

[build_ext]
compiler=mingw32

[config]
compiler=mingw32

but I still get this problem. I'm sure this is a simple problem and
I'm just missing something. Any help would be great. Thanks!

Bill

Robert Bradshaw

unread,
Mar 4, 2010, 4:03:41 AM3/4/10
to cython...@googlegroups.com
On Mar 3, 2010, at 1:59 PM, wflynny wrote:

> Hi -
>
> I am new to cython and have run into a problem using pyximport. I am
> using Windows XP, 32-bit and python 2.5.
>
> I created a file called hellow.pyx that simply says
> print "Hello World".
>
> Then I went into my command prompt and typed the following:
>>>> import pyximport; pyximport.install()
>>>> import hellow
> gcc: and: No such file or directory

That is a strange line...

Just to be sure, have you tried doing this with a setup.py?

- Robert


wflynny

unread,
Mar 11, 2010, 1:24:13 PM3/11/10
to cython-users
Yes. I just tested this method by creating a setup.py file that reads

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("helloworld", ["hellow.pyx"])]
)

then ran "python setup.py build_ext --inplace". Then I opened python:
>>> import helloworld
Hello World

This means it works one way but not the other, correct? I apologize
for taking a week to respond. Any advice?

On Mar 4, 4:03 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:


> On Mar 3, 2010, at 1:59 PM, wflynny wrote:
>
> > Hi -
>

> > I amnewto cython and have run into a problem using pyximport. I am

Message has been deleted

Chris Barker

unread,
Mar 11, 2010, 1:58:25 PM3/11/10
to cython...@googlegroups.com
wflynny wrote:
> However, I just did some more testing, and what seems to work is if I
> leave the helloworld.py with the .py extension. Then I run the
> following:
>
>>>> import pyximport; pyximport.install(pyimport=True)
>>>> import helloworld
> Hello World

> This seems to work so I may just bypass the problem this way!

In this case, you are simply importing a regular old python module -- no
Cython involved -- that's why it works.

I'm no expert, but I suspect that pywimport doesn't play well with the
cygwin compiler. pyximport is pretty nifty, but really not that useful
for significant projects anyway, I'd just go with the regular old
dist_utils build option, rather than trying to debug this.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

wflynny

unread,
Mar 11, 2010, 2:41:54 PM3/11/10
to cython-users
Chris -

Yes I realized this mistake a minute or two after I posted and tried
removing the post - seems as though you caught me though. Thanks for
your suggestion; that is what I have been doing in the mean time so I
guess I will stick with it.

> Chris.Bar...@noaa.gov

josef...@gmail.com

unread,
Mar 11, 2010, 3:02:11 PM3/11/10
to cython...@googlegroups.com

I don't have any problem with pyximport with WindowsXP 32, mingw3.4.5
cython 0.12.1

From your original error message, it looks like the path name with
spaces is not properly quoted
C:\Documents and Settings

Can you try with a different build_dir ?
I'm not sure how to do it

import pyximport; pyximport.install(build_dir=".",build_in_temp=False)

but this still saves the compiled file in
>>> import hellowo3
>>> hellowo3.__file__
'C:\\Documents and Settings\\josef/.pyxbld\\lib.win32-2.5\\hellowo3.pyd'

Josef

Reply all
Reply to author
Forward
0 new messages