[SciPy-dev] Strange import-related bug caused by scipy

Fernando Perez fperez at colorado.edu
Thu Nov 13 16:19:53 CST 2003

Here's how to reproduce it.

Start with two very simple files:

planck[import]> cat one.py
from weave import inline,converters

planck[import]> cat two.py
import scipy

import one

Here's what happens if you execfile() these:

planck[import]> python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> execfile("one.py")
 >>> execfile("two.py")
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "two.py", line 3, in ?
     import one
   File "one.py", line 1, in ?
     from weave import inline,converters
ImportError: cannot import name converters

Now, the funny thing is that if you reverse the order of the imports in two.py 
and put 'import scipy' _last_, then there's no problem.   Somehow, the games 
scipy plays with the import mechanism are breaking something.

For the time being, I've resorted to putting my 'import scipy' statements last 
in my code.



More information about the Scipy-dev mailing list