Install in virtualenv gives "ImportError: No module named backports.functools_lru_cache" #71

Closed
fboender opened this Issue Nov 24, 2015 · 8 comments

Projects

None yet

3 participants

@fboender

When installing irclib in a virtualenv through Pip, I receive a an error when trying to import "irc.bot" and "irc.client". Full transcription:

0 fboender @ jib ~/Temp/irctest $ . bin/activate
(irctest)0 fboender @ jib ~/Temp/irctest $ pip install irc
Downloading/unpacking irc
  Downloading irc-13.2-py2.py3-none-any.whl (75kB): 75kB downloaded
Downloading/unpacking jaraco.itertools (from irc)
  Downloading jaraco.itertools-1.7-py2.py3-none-any.whl
Downloading/unpacking pytz (from irc)
  Downloading pytz-2015.7-py2.py3-none-any.whl (476kB): 476kB downloaded
Downloading/unpacking jaraco.logging (from irc)
  Downloading jaraco.logging-1.2.zip
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.logging/setup.py) egg_info for package jaraco.logging

    Installed /home/fboender/Temp/irctest/build/jaraco.logging/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Downloading/unpacking jaraco.functools>=1.5 (from irc)
  Downloading jaraco.functools-1.6.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.functools/setup.py) egg_info for package jaraco.functools

    Installed /home/fboender/Temp/irctest/build/jaraco.functools/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Downloading/unpacking jaraco.collections (from irc)
  Downloading jaraco.collections-1.3-py2.py3-none-any.whl
Downloading/unpacking jaraco.text (from irc)
  Downloading jaraco.text-1.4.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.text/setup.py) egg_info for package jaraco.text
    zip_safe flag not set; analyzing archive contents...

    Installed /home/fboender/Temp/irctest/build/jaraco.text/hgtools-6.3-py2.7.egg

Downloading/unpacking six (from irc)
  Downloading six-1.10.0-py2.py3-none-any.whl
Downloading/unpacking inflect (from jaraco.itertools->irc)
  Downloading inflect-0.2.5-py2.py3-none-any.whl (58kB): 58kB downloaded
Downloading/unpacking more-itertools (from jaraco.itertools->irc)
  Downloading more-itertools-2.2.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/more-itertools/setup.py) egg_info for package more-itertools

Downloading/unpacking tempora (from jaraco.logging->irc)
  Downloading tempora-1.3.zip
  Running setup.py (path:/home/fboender/Temp/irctest/build/tempora/setup.py) egg_info for package tempora

    Installed /home/fboender/Temp/irctest/build/tempora/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Downloading/unpacking jaraco.classes (from jaraco.collections->irc)
  Downloading jaraco.classes-1.2.zip
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.classes/setup.py) egg_info for package jaraco.classes
    zip_safe flag not set; analyzing archive contents...

    Installed /home/fboender/Temp/irctest/build/jaraco.classes/hgtools-6.3-py2.7.egg

Downloading/unpacking jaraco.context>=1.3 (from jaraco.text->irc)
  Downloading jaraco.context-1.5.2.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.context/setup.py) egg_info for package jaraco.context

    Installed /home/fboender/Temp/irctest/build/jaraco.context/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Downloading/unpacking jaraco.apt (from jaraco.context>=1.3->jaraco.text->irc)
  Downloading jaraco.apt-1.0.zip
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.apt/setup.py) egg_info for package jaraco.apt
    zip_safe flag not set; analyzing archive contents...

    Installed /home/fboender/Temp/irctest/build/jaraco.apt/hgtools-6.3-py2.7.egg

Downloading/unpacking yg.lockfile (from jaraco.context>=1.3->jaraco.text->irc)
  Downloading yg.lockfile-2.1.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/yg.lockfile/setup.py) egg_info for package yg.lockfile

    Installed /home/fboender/Temp/irctest/build/yg.lockfile/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Downloading/unpacking zc.lockfile (from yg.lockfile->jaraco.context>=1.3->jaraco.text->irc)
  Downloading zc.lockfile-1.1.0.zip
  Running setup.py (path:/home/fboender/Temp/irctest/build/zc.lockfile/setup.py) egg_info for package zc.lockfile

    warning: no files found matching '*.rst'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
Downloading/unpacking jaraco.timing (from yg.lockfile->jaraco.context>=1.3->jaraco.text->irc)
  Downloading jaraco.timing-1.1.5.tar.gz
  Running setup.py (path:/home/fboender/Temp/irctest/build/jaraco.timing/setup.py) egg_info for package jaraco.timing

    Installed /home/fboender/Temp/irctest/build/jaraco.timing/setuptools_scm-1.9.0-py2.7.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

Requirement already satisfied (use --upgrade to upgrade): setuptools in ./lib/python2.7/site-packages (from zc.lockfile->yg.lockfile->jaraco.context>=1.3->jaraco.text->irc)
Installing collected packages: irc, jaraco.itertools, pytz, jaraco.logging, jaraco.functools, jaraco.collections, jaraco.text, six, inflect, more-itertools, tempora, jaraco.classes, jaraco.context, jaraco.apt, yg.lockfile, zc.lockfile, jaraco.timing
  Running setup.py install for jaraco.logging
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco.logging-1.2-py2.7-nspkg.pth
  Running setup.py install for jaraco.functools
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco.functools-1.6-py2.7-nspkg.pth
  Running setup.py install for jaraco.text
    /home/fboender/Temp/irctest/local/lib/python2.7/site-packages/setuptools/dist.py:16: UserWarning: Module jaraco was already imported from None, but /home/fboender/Temp/irctest/build/jaraco.text is being added to sys.path
      import pkg_resources

  Running setup.py install for more-itertools

  Running setup.py install for tempora
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Installing calc-prorate script to /home/fboender/Temp/irctest/bin
  Running setup.py install for jaraco.classes

  Running setup.py install for jaraco.context
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco.context-1.5.2-py2.7-nspkg.pth
  Running setup.py install for jaraco.apt
    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco/__init__.py (namespace package)

    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco.apt-1.0-py2.7-nspkg.pth
  Running setup.py install for yg.lockfile
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/yg/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/yg.lockfile-2.1-py2.7-nspkg.pth
  Running setup.py install for zc.lockfile

    warning: no files found matching '*.rst'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/zc/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/zc.lockfile-1.1.0-py2.7-nspkg.pth
  Running setup.py install for jaraco.timing
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded

    Skipping installation of /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco/__init__.py (namespace package)
    Installing /home/fboender/Temp/irctest/lib/python2.7/site-packages/jaraco.timing-1.1.5-py2.7-nspkg.pth
Successfully installed irc jaraco.itertools pytz jaraco.logging jaraco.functools jaraco.collections jaraco.text six inflect more-itertools tempora jaraco.classes jaraco.context jaraco.apt yg.lockfile zc.lockfile jaraco.timing
Cleaning up...
(irctest)0 fboender @ jib ~/Temp/irctest $ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import irc.bot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fboender/Temp/irctest/local/lib/python2.7/site-packages/irc/bot.py", line 14, in <module>
    import irc.client
  File "/home/fboender/Temp/irctest/local/lib/python2.7/site-packages/irc/client.py", line 68, in <module>
    from jaraco.functools import Throttler
  File "/home/fboender/Temp/irctest/local/lib/python2.7/site-packages/jaraco/functools.py", line 9, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named backports.functools_lru_cache
@fboender

Just noticed the "setuptools_scm functionality is degraded" message. It's probably related to that. I have no idea what's causing that. I'll investigate further.

@fboender

The problem is indeed related to old setuptools version. This particular virtualenv was ran on Ubuntu 14.04. To fix the issue, upgrade the version of pip, wheel and setuptools in your virtualenv:

pip install -U pip wheel setuptools

Afterwards, reinstall irc:

pip install irc

Now it works:

>>> import irc.bot 
>>> 
@fboender fboender closed this Nov 24, 2015
@jaraco
Owner
jaraco commented Nov 24, 2015

See also the explanation in #66. I think I'll update the setup script to include that dependency when setuptools is old.

@jaraco
Owner
jaraco commented Nov 24, 2015

Digging just a bit further, it seems that the declared dependency is in jaraco.functools, but more importantly, the issue lies with pip, which can't even be detected for wheel-based installs, so I think the best that could be done is to advertise the issue (which is done by this ticket and the sister ticket), to recommend that everyone upgrade their packaging tools.

I'll also mention that this issue only affects Python 2, so switching to Python 3 also corrects the issue.

@fboender

Another point in favour of Python 3. :-)

@Xenthys
Xenthys commented Dec 12, 2015

Hi, doing that didn't work on a Ubuntu 15.04 x64 VPS, I needed to pip install functools32 and to modify the import line functools ---> functools32 to get it working.

@jaraco
Owner
jaraco commented Dec 12, 2015

Hi @Xenthys. I'd recommend instead simply pip install backports.functools_lru_cache. That's the import that's missed when irc (or jaraco.functools) is installed by Setuptools < 0.7 or Pip < 6.0.

As I mentioned above, I was considering updating the setup script to detect when being installed by an old version of setuptools, but I realized that older pip is a much more common scenario and as far as I know, there's no way to hook into pip during an install to check that it is new enough to support the environment marked dependencies.

However, to be more lenient, I've released a new functools 1.8 with more generous handling of a missing lru_cache module, which also bypasses this issue.

@Xenthys
Xenthys commented Dec 12, 2015

Good, thanks for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment