ImportError: cannot import name reduce

371 views
Skip to first unread message

Elke Schaper

unread,
Mar 16, 2015, 12:19:17 PM3/16/15
to gc3...@googlegroups.com
Dear all,

I've just tried to install the current rev. 4188.
The installation did not throw any errors.

However, I could not run Gc3pie (Python 2.7.5):
>>> from gc3libs.cmdline import SessionBasedScript
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/python/lib/python2.7/site-packages/gc3pie-2.3.dev-py2.7.egg/gc3libs/cmdline.py", line 69, in <module>
    from gc3libs.session import Session
  File "/path/to/python/lib/python2.7/site-packages/gc3pie-2.3.dev-py2.7.egg/gc3libs/session.py", line 37, in <module>
    from gc3libs.workflow import TaskCollection
  File "/path/to/python/lib/python2.7/site-packages/gc3pie-2.3.dev-py2.7.egg/gc3libs/workflow.py", line 36, in <module>
    from gc3libs.compat.toposort import toposort
  File "/path/to/python/lib/python2.7/site-packages/gc3pie-2.3.dev-py2.7.egg/gc3libs/compat/toposort.py", line 43, in <module>
    from functools import reduce as _reduce
ImportError: cannot import name reduce


On the other hand this worked fine:
>>> import functools
>>> functools.reduce
<built-in function reduce>
>>> from functools import reduce as _reduce


Any ideas?

Thank you,

Elke

Riccardo Murri

unread,
Mar 16, 2015, 4:23:36 PM3/16/15
to gc3...@googlegroups.com
Hi Elke,

> from gc3libs.compat.toposort import toposort
> File
> "/path/to/python/lib/python2.7/site-packages/gc3pie-2.3.dev-py2.7.egg/gc3libs/compat/toposort.py",
> line 43, in <module>
> from functools import reduce as _reduce
> ImportError: cannot import name reduce

The `functools.py` file was removed from GC3Pie recently; you likely
have still a stale `functools.pyc` or `functools.pyo` lying around in
your SVN working copy. Please remove it, and try again.

Ciao,
R

Elke Schaper

unread,
Mar 16, 2015, 5:06:08 PM3/16/15
to gc3...@googlegroups.com

Hi Riccardo,

Great, a legacy copy of functools.py was indeed the problem.

Thus now I deleted my copy of gc3pie and checked everything out from scratch - I’m sure there are more elegant solutions :)

Reinstallation then worked fine.


Thanks!

Elke

Henrik Madsen

unread,
Feb 10, 2017, 4:07:56 AM2/10/17
to gc3pie
Hi

Sorry to dig up this old thread, but I have the exact same problem, and I have no idea how to fix it?

Just started Python this week. Used anaconda 4.3.0 (Python 3.6.0).

I can't find any functools.py / .pyc / .pyo on my windows 10 machine.

SVN is not recognized...

I don't have functools in my Conda or PIP list, so can't really uninstall it

Hope you guys can help

Riccardo Murri

unread,
Feb 10, 2017, 4:15:36 AM2/10/17
to gc3...@googlegroups.com
Hello Henrik,

unless yours is a problem with GC3Pie specifically (unlikely, since
you mention you just started with Python), this is probably the wrong
forum to ask: no one of us uses Windows so I doubt you can get any
useful suggestions here.

For this kind of generic Python questions, you might be better off
asking the makers of Anaconda: https://www.continuum.io/support

Ciao,
R

Henrik Madsen

unread,
Feb 10, 2017, 4:22:17 AM2/10/17
to gc3pie
You are right, my problem is not related to GC3Pie.

It's just that I have the same problem as OP with regards to using functools, so I guess the solution is the same for me as it was for him :-)

I'll ask over in the Anaconda forum
Reply all
Reply to author
Forward
0 new messages