Discussion:
scons not playing well with scipy?
Sandesh Singh
2011-01-03 15:37:28 UTC
Permalink
Hi.

On doing -

import scipy.io.arff

in a SConstruct file, I get the error:

AttributeError: 'builtin_function_or_method' object has no attribute 'dispatch':
File "/home/sandesh247/portal/tmp/scons_exp/marsyas/SConstruct", line 3:
import scipy.io.arff
File "/usr/lib/python2.6/dist-packages/scipy/__init__.py", line 18:
from numpy import oldnumeric
File "/usr/lib/python2.6/dist-packages/numpy/oldnumeric/__init__.py", line 14:
from compat import *
File "/usr/lib/python2.6/dist-packages/numpy/oldnumeric/compat.py", line 98:
class Unpickler(pickle.Unpickler):
File "/usr/lib/python2.6/dist-packages/numpy/oldnumeric/compat.py", line 102:
dispatch = copy.copy(pickle.Unpickler.dispatch)

Any ideas on how to fix this?

Thanks.

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2695657

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Gary Oberbrunner
2011-01-03 18:23:35 UTC
Permalink
Doesn't look scons-related on the face of it. Does that import statement
work in a plain python file (or with "python -c 'import scipy.io.arff'")?
Do you have more than one python on that machine?

-- Gary
Post by Sandesh Singh
Hi.
On doing -
import scipy.io.arff
import scipy.io.arff
from numpy import oldnumeric
from compat import *
dispatch = copy.copy(pickle.Unpickler.dispatch)
Any ideas on how to fix this?
Thanks.
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2695657
--
-- Gary

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2695685

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Hans-Martin von Gaudecker
2011-01-03 18:36:43 UTC
Permalink
Post by Gary Oberbrunner
Doesn't look scons-related on the face of it.
I can offer some support for that diagnosis -- I ran into the same issue trying to document code that imports scipy modules using Sphinx (the code worked standalone, though). So it seems like SciPy doesn't play well with some forms of other tools and you'll probably be better off on the SciPy mailing list.

Best,
Hans-Martin
Post by Gary Oberbrunner
Does that import statement work in a plain python file (or with "python -c 'import scipy.io.arff'")? Do you have more than one python on that machine?
-- Gary
Hi.
On doing -
import scipy.io.arff
------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2695687

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Dirk Baechle
2011-01-03 19:16:42 UTC
Permalink
Hi Sandesh,

my guess is that the
Post by Sandesh Singh
from compat import *
is the problem. Depending on the current PYTHONPATH it seems to find the SCons "compat" module first, which reloads the "pickle" by

if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is None:
rename_module('pickle', 'cPickle')

. You could try to set and export the "*TEST_HACK" variable above in your shell environment, such that the overwrite doesn't happen...which would be another horrible hack by itself. But who cares, as long as it works? ;)

Best regards,

Dirk

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2695690

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Sandesh Singh
2011-01-05 14:36:51 UTC
Permalink
Post by Dirk Baechle
Hi Sandesh,
my guess is that the
Post by Sandesh Singh
from compat import *
is the problem. Depending on the current PYTHONPATH it seems to find the SCons "compat" module first, which reloads the "pickle" by
rename_module('pickle', 'cPickle')
. You could try to set and export the "*TEST_HACK" variable above in your shell environment, such that the overwrite doesn't happen...which would be another horrible hack by itself. But who cares, as long as it works? ;)
Pardon the late reply.

Yes, the export does work. However, there is no PYTHONPATH set.

I tried changing the offending line in oldnumeric/__init__.py to:

from numpy.oldnumeric.compat import *

However, it doesn't help.

While I do believe this bug (if it is one) should be fixed in scipy/numpy, is there any way to resolve this name collision?

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2696088

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Dirk Baechle
2011-01-05 17:58:55 UTC
Permalink
Post by Sandesh Singh
Yes, the export does work. However, there is no PYTHONPATH set.
The start scripts for SCons amend sys.path by prepending a few paths (that's what I actually meant, when talking about PYTHONPATH). Confirm this with a "print sys.path" before the offending import, if you like.

------------------------------------------------------
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&dsMessageId=2696142

To unsubscribe, send an e-mail to [users-***@scons.tigris.org].
Loading...