You are not logged in.
When I try to run a Python script: python dbmakefakelib.py (it's for Dropbox) I get an error:
Traceback (most recent call last):
File "dbmakefakelib.py", line 1, in <module>
import commands, re, os, threading, time, sys
File "/usr/local/lib/python2.6/threading.py", line 13, in <module>
from functools import wraps
File "/usr/local/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
It seems to be coming from inside Python's own source files. Has anyone else I had this problem? I figure this out and Google's not helping much.
Last edited by matthewbauer (2009-07-21 22:10:36)
Libertarian Arch Linux User
Offline
Weird. Can you open up a python shell and manually type:
import commands, re, os, threading, time, sys
I'd also try reinstalling python.
Last edited by Profjim (2009-08-25 18:00:02)
Offline
Same problem here. Reduce is a function not a module, which would mean something is a bit off in the source.
UPDATE
I can confirm this is a problem. Generating a patch.
UPDATE
--- /usr/lib/python2.6/functools.py 2009-10-27 09:49:47.000000000 -0400
+++ functools.py 2009-10-27 09:49:31.000000000 -0400
@@ -7,7 +7,7 @@
# Copyright (C) 2006 Python Software Foundation.
# See C source code for _functools credits/copyright
-from _functools import partial, reduce
+from _functools import partial
# update_wrapper() and wraps() are tools to help write
# wrapper functions that can handle naive introspection
Save the above patch to
functools.patch
then run the following command:
# patch -u /usr/lib/python2.6/functools.py functools.patch
Last edited by timetrap (2009-10-27 14:08:34)
Offline
Same problem here. Reduce is a function not a module, which would mean something is a bit off in the source.
I can confirm this is a problem. Generating a patch.
Please don't. matthewbauer has an old version of python installed. So do you. I do not get that error on python 2.6.3-2.
By the way, you are allowed to import functions from modules. I do it all the time, though functools.partial is much more useful that functools.reduce.
Offline
timetrap wrote:Same problem here. Reduce is a function not a module, which would mean something is a bit off in the source.
I can confirm this is a problem. Generating a patch.
Please don't. matthewbauer has an old version of python installed. So do you. I do not get that error on python 2.6.3-2.
By the way, you are allowed to import functions from modules. I do it all the time, though functools.partial is much more useful that functools.reduce.
Really? You can't do that with reduce. It's a built-in function. Try this:
import reduce
It fails with an ImportError. You can't do this in the manner that functools.py is trying. And I'm not running an older version of python (currently 2.6.3-2). This is an error.
But I think we need Allen to weigh in on this, he's the package maintainer.
UPDATE
Emailed Allen ...
Last edited by timetrap (2009-10-27 14:22:38)
Offline
You are all using old versions of python (2.6.4-1 is out today), and quickly running that import line shows no errors.
Edit: in fact it appears to work with 2.6.3-2 (i686)....
Offline
You are all using old versions of python (2.6.4-1 is out today), and quickly running that import line shows no errors.
Edit: in fact it appears to work with 2.6.3-2 (i686)....
Damn you Allan! *Shakes fist at the sky*. You and your superior version numbers!
But seriously. The line in functools IS messed up. Right? You can't "import reduce" any more than you can "import print".
Offline
But seriously. The line in functools IS messed up. Right? You can't "import reduce" any more than you can "import print".
No. They are importing the 'reduce' function (or class.. etc.) from the _functools module. You are assuming they are importing a 'reduce' module.
Last edited by rson451 (2009-10-27 14:47:00)
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
It is not "import reduce", it is:
from _functools import reduce
And you can import functions from within modules....
Offline
AH. I see. I think. But why, doesn't it work at all? Once I remove the reduce line, it works. Which leaves me a little confused.
Offline
I have no idea why this is not working. i686 or x86_64?
Offline
i686.
What I am understanding is this:
the module functools can be addressed internally via _functools, thus allowing an importing of functions from within itself. While there is a partial function there is no reduce function declared inside functools. So I left with a little confusion. Why would reduce even need to be imported if reduce is a built-in function?
I did find this bug report: http://bugs.python.org/issue1739906 But I'm still not sure what reduce is actually doing, in my functools.
Last edited by timetrap (2009-10-27 15:02:56)
Offline
In python 3.x the builtin reduce() was removed.
Removed reduce(). Use functools.reduce() if you really need it; however, 99 percent of the time an explicit for loop is more readable.
This change have been backported to 2.6 by doing this:
The addition of functools.reduce() as a synonym for the built-in reduce() function.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
If you're still running 2.6.3-2 please try this. I want to make sure I'm not crazy.
>>> import functools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
Offline
> python
Python 2.6.3 (r263:75183, Oct 4 2009, 11:40:05)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
>>>
All looks good to me with 2.6.3-2
Offline
So ... what happened? I installed python after a clean install of arch (on 10-24-2009).
pacman -Ql | grep functools
python /usr/lib/python2.6/functools.py
python /usr/lib/python2.6/functools.pyc
python /usr/lib/python2.6/functools.pyo
python /usr/lib/python2.6/lib-dynload/_functools.so
python /usr/lib/python2.6/test/test_functools.py
python /usr/lib/python2.6/test/test_functools.pyc
python /usr/lib/python2.6/test/test_functools.pyo
My current mirror is http://distro.ibiblio.org/pub/linux/dis … po/os/i686 ...
I also just ran
pacman -Sf python
# same error as above, reinstalled 2.6.3-2
pacman -Scc
pacman -Sf python
# same error as above, reinstalled 2.6.3-2
# I swithced mirrors to rit.edu
pacman -Syu
# upgraded python to 2.6.4-1
# same error.
Last edited by timetrap (2009-10-27 15:28:28)
Offline
So I've upgraded to python 2.6.4-1, and get the same error. Just to be on the safe side, I'll reboot.
Python 2.6.4 (r264:75706, Oct 27 2009, 06:16:59)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
Following a reboot, it works. Strange. Maybe something was locked? I'm not running anything in the background ...
Last edited by timetrap (2009-10-27 15:35:25)
Offline
Okay, I've recreated the problem, its a bit weird. All of the following commands are in the same terminal:
Python 2.6.4 (r264:75706, Oct 27 2009, 06:16:59)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> import functools
>>> import _functools
>>>
Running dbmakefakelib.py (which is linked from the archwiki), and makes all kind of badness happen.
.dropbox-dist/ python dbmakefakelib.py
Traceback (most recent call last):
File "dbmakefakelib.py", line 2, in <module>
import commands, re, os, threading, time, sys
File "/usr/lib/python2.6/threading.py", line 13, in <module>
from functools import wraps
File "/usr/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
.dropbox-dist/ python
Python 2.6.4 (r264:75706, Oct 27 2009, 06:16:59)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import functools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
>>> import _functools
>>> import threading
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/threading.py", line 13, in <module>
from functools import wraps
File "/usr/lib/python2.6/functools.py", line 10, in <module>
from _functools import partial, reduce
ImportError: cannot import name reduce
>>>
Offline
I'm having the same problem running the python files for Dropbox. Was a solution ever found? I'm unable to get Dropbox to actually work for me and I'm wondering if it's somehow related to this python issue.
Offline
If you notice in the .dropbox-dist/ directory, they have their own version of _functools.so. If I copy the real one into that dir (cp /usr/lib/python2.6/lib-dynload/_functools.so ~/.dropbox-dist/), then the python script will at least execute, but I don't believe that it's executing correctly because it does not spew out the info mentioned on the Dropbox Wiki (http://wiki.dropbox.com/TipsAndTricks/T … nuxInstall).
So that leads me to think that for some reason it's the provided _functools.so file that is the problem.
Offline