Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

python - Installing functools gives me AttributeError 'module' object has no attribute 'compose'

I installed Ubuntu 12.04 64 bit on a new system, and cannot install functools. I have installed this multiple times but do not remember getting this error, and cannot find any solution through Google. What do I need to do?

(myvenv)bobs@myvenv:~$ pip install functools
Downloading/unpacking functools
  Downloading functools-0.5.tar.gz
  Running setup.py egg_info for package functools
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
        from setuptools.extension import Extension, Library
      File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
        from setuptools.dist import _get_unpatched
      File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
        from setuptools.compat import numeric_types, basestring
      File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
        import httplib
      File "/usr/lib/python2.7/httplib.py", line 71, in <module>
        import socket
      File "/usr/lib/python2.7/socket.py", line 49, in <module>
        from functools import partial
      File "functools.py", line 72, in <module>
        globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
    AttributeError: 'module' object has no attribute 'compose'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>

    from setuptools.extension import Extension, Library

  File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>

    from setuptools.dist import _get_unpatched

  File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>

    from setuptools.compat import numeric_types, basestring

  File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>

    import httplib

  File "/usr/lib/python2.7/httplib.py", line 71, in <module>

    import socket

  File "/usr/lib/python2.7/socket.py", line 49, in <module>

    from functools import partial

  File "functools.py", line 72, in <module>

    globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)

AttributeError: 'module' object has no attribute 'compose'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/bobs/.virtualenvs/myvenv/build/functools
Storing complete log in /home/bobs/.pip/pip.log
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Python2.7 comes with the functools module included.

You can install functools32 if you want to get the lru-cache decorator, which was introduced with Python3.2.

Edit: I actually checked this. I got the same error when I tried to pip-install functools with Python2.7. Simply do import functools and proceed as usual.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...