Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.py test fails with ImportError: No module named packages.urllib3.response #722

Closed
dfc opened this issue Apr 24, 2014 · 8 comments
Closed

Comments

@dfc
Copy link

dfc commented Apr 24, 2014

I am having trouble building the latest beets. (Ignore the versioned beets directory. this is just part of uupdate and building the debian package)

I can run python setup.py build with no problems:


dfc@ronin:~/tmp/beets-1.3.6-rc1$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/beets
copying beets/importer.py -> build/lib.linux-x86_64-2.7/beets
copying beets/mediafile.py -> build/lib.linux-x86_64-2.7/beets
copying beets/library.py -> build/lib.linux-x86_64-2.7/beets
copying beets/__init__.py -> build/lib.linux-x86_64-2.7/beets
copying beets/plugins.py -> build/lib.linux-x86_64-2.7/beets
copying beets/vfs.py -> build/lib.linux-x86_64-2.7/beets
creating build/lib.linux-x86_64-2.7/beets/ui
copying beets/ui/migrate.py -> build/lib.linux-x86_64-2.7/beets/ui
copying beets/ui/__init__.py -> build/lib.linux-x86_64-2.7/beets/ui
copying beets/ui/commands.py -> build/lib.linux-x86_64-2.7/beets/ui
creating build/lib.linux-x86_64-2.7/beets/autotag
copying beets/autotag/__init__.py -> build/lib.linux-x86_64-2.7/beets/autotag
copying beets/autotag/hooks.py -> build/lib.linux-x86_64-2.7/beets/autotag
copying beets/autotag/match.py -> build/lib.linux-x86_64-2.7/beets/autotag
copying beets/autotag/mb.py -> build/lib.linux-x86_64-2.7/beets/autotag
creating build/lib.linux-x86_64-2.7/beets/util
copying beets/util/enumeration.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/functemplate.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/bluelet.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/confit.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/pipeline.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/__init__.py -> build/lib.linux-x86_64-2.7/beets/util
copying beets/util/artresizer.py -> build/lib.linux-x86_64-2.7/beets/util
creating build/lib.linux-x86_64-2.7/beets/dbcore
copying beets/dbcore/db.py -> build/lib.linux-x86_64-2.7/beets/dbcore
copying beets/dbcore/__init__.py -> build/lib.linux-x86_64-2.7/beets/dbcore
copying beets/dbcore/query.py -> build/lib.linux-x86_64-2.7/beets/dbcore
copying beets/dbcore/types.py -> build/lib.linux-x86_64-2.7/beets/dbcore
creating build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/ihate.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/discogs.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/ftintitle.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/info.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/play.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/bench.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/__init__.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/mpdupdate.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/importfeeds.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/fromfilename.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/rewrite.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/echonest.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/inline.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/lyrics.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/fetchart.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/mpdstats.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/duplicates.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/smartplaylist.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/convert.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/beatport.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/missing.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/zero.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/keyfinder.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/random.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/chroma.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/replaygain.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/echonest_tempo.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/mbsync.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/mbcollection.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/fuzzy.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/embedart.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/scrub.py -> build/lib.linux-x86_64-2.7/beetsplug
copying beetsplug/the.py -> build/lib.linux-x86_64-2.7/beetsplug
creating build/lib.linux-x86_64-2.7/beetsplug/bpd
copying beetsplug/bpd/__init__.py -> build/lib.linux-x86_64-2.7/beetsplug/bpd
copying beetsplug/bpd/gstplayer.py -> build/lib.linux-x86_64-2.7/beetsplug/bpd
creating build/lib.linux-x86_64-2.7/beetsplug/web
copying beetsplug/web/__init__.py -> build/lib.linux-x86_64-2.7/beetsplug/web
creating build/lib.linux-x86_64-2.7/beetsplug/lastgenre
copying beetsplug/lastgenre/__init__.py -> build/lib.linux-x86_64-2.7/beetsplug/lastgenre
running egg_info
writing requirements to beets.egg-info/requires.txt
writing beets.egg-info/PKG-INFO
writing top-level names to beets.egg-info/top_level.txt
writing dependency_links to beets.egg-info/dependency_links.txt
writing entry points to beets.egg-info/entry_points.txt
reading manifest file 'beets.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'man/beet.1'
warning: no files found matching 'man/beetsconfig.5'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
writing manifest file 'beets.egg-info/SOURCES.txt'
copying beets/config_default.yaml -> build/lib.linux-x86_64-2.7/beets
copying beets/ui/completion_base.sh -> build/lib.linux-x86_64-2.7/beets/ui
creating build/lib.linux-x86_64-2.7/beetsplug/web/static
copying beetsplug/web/static/backbone.js -> build/lib.linux-x86_64-2.7/beetsplug/web/static
copying beetsplug/web/static/beets.css -> build/lib.linux-x86_64-2.7/beetsplug/web/static
copying beetsplug/web/static/beets.js -> build/lib.linux-x86_64-2.7/beetsplug/web/static
copying beetsplug/web/static/jquery.js -> build/lib.linux-x86_64-2.7/beetsplug/web/static
copying beetsplug/web/static/underscore.js -> build/lib.linux-x86_64-2.7/beetsplug/web/static
creating build/lib.linux-x86_64-2.7/beetsplug/web/templates
copying beetsplug/web/templates/index.html -> build/lib.linux-x86_64-2.7/beetsplug/web/templates
copying beetsplug/lastgenre/genres-tree.yaml -> build/lib.linux-x86_64-2.7/beetsplug/lastgenre
copying beetsplug/lastgenre/genres.txt -> build/lib.linux-x86_64-2.7/beetsplug/lastgenre

When I try python setup.py test I get the following error:


dfc@ronin:~/tmp/beets-1.3.6-rc1$ python setup.py test 
running test
Searching for responses
Reading https://pypi.python.org/simple/responses/
Best match: responses 0.2.0
Downloading https://pypi.python.org/packages/source/r/responses/responses-0.2.0.tar.gz#md5=2e9ce398d5de6ad9a43abe16d4d7ae06
Processing responses-0.2.0.tar.gz
Writing /tmp/easy_install-AVOLyH/responses-0.2.0/setup.cfg
Running responses-0.2.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-AVOLyH/responses-0.2.0/egg-dist-tmp-v8wYGC

Installed /home/dfc/tmp/beets-1.3.6-rc1/responses-0.2.0-py2.7.egg
running egg_info
writing requirements to beets.egg-info/requires.txt
writing beets.egg-info/PKG-INFO
writing top-level names to beets.egg-info/top_level.txt
writing dependency_links to beets.egg-info/dependency_links.txt
writing entry points to beets.egg-info/entry_points.txt
reading manifest file 'beets.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'man/beet.1'
warning: no files found matching 'man/beetsconfig.5'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
writing manifest file 'beets.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "setup.py", line 117, in <module>
    'Programming Language :: Python :: 2.7',
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/test.py", line 146, in run
    self.with_project_on_sys_path(self.run_tests)
  File "/usr/lib/python2.7/dist-packages/setuptools/command/test.py", line 127, in with_project_on_sys_path
    func()
  File "/usr/lib/python2.7/dist-packages/setuptools/command/test.py", line 167, in run_tests
    testRunner=self._resolve_as_ep(self.test_runner),
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 115, in loadTestsFromName
    test = obj()
  File "/home/dfc/tmp/beets-1.3.6-rc1/test/testall.py", line 42, in suite
    s.addTest(__import__(modname).suite())
  File "/home/dfc/tmp/beets-1.3.6-rc1/test/test_art.py", line 20, in <module>
    import responses
  File "/home/dfc/tmp/beets-1.3.6-rc1/responses-0.2.0-py2.7.egg/responses.py", line 36, in <module>
    from requests.packages.urllib3.response import HTTPResponse
ImportError: No module named packages.urllib3.response
dfc@ronin:~/tmp/beets-1.3.6-rc1$

@dfc
Copy link
Author

dfc commented Apr 25, 2014

I am way out of my comfort zone with this one. I am not really sure what is going on. I am confused with the requests.packages. bit. I can import urllib3.response just fine but not with the requests.packages. bit preprended:


$ bpython
>>> from requests.packages.urllib3.response import HTTPResponse
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: No module named packages.urllib3.response
>>> from urllib3.response import HTTPResponse
>>> HTTPResponse
<class 'urllib3.response.HTTPResponse'>
>>>

@geigerzaehler
Copy link

Seems that you are using an old version of requests from your system. I'm not sure but I think you need at least 2.0.

@dfc
Copy link
Author

dfc commented Apr 25, 2014

Seems that you are using an old version of requests from your system. I'm not sure but I think you need at least 2.0.

You have to give me more credit than that, Debian has requests 2.2.1. If I am going to waste your time I am going to at least try and make it challenging. I think I found the problem but it does not make any sense to me. It seems debian has ripped out the packages.urllib3 bit. The patch is:

http://anonscm.debian.org/viewvc/python-modules/packages/requests/trunk/debian/patches/02_use-system-chardet-and-urllib3.patch?revision=27448&view=markup

Does that make any sense? Is this a Debian bug or a responses bug?

@sampsyo
Copy link
Member

sampsyo commented Apr 25, 2014

Well, that's a mysterious one. In my experience, Debian doesn't like people to "vendor" packages (include another package's source internally), which is exactly what requests is doing here. Their solution is to modify all packages that do vendoring to instead depend on the corresponding external Debian package. Normally this is fine, but here responses is depending on the existence of the vendored urllib3.

I'm not sure what the right solution to this is. It would appear that responses is totally broken on Debian—surely someone else must have run into this before?

@dfc
Copy link
Author

dfc commented Apr 25, 2014

Dropbox accepted my pull request: getsentry/responses#12

This is no longer an issue for me. I am not sure how long it takes for the patch to propagate, but once it does there should be no problem. Seeing as I am the only one that was troubled by this I am going to close this. Thanks for all your help samps and geiger.

@dfc dfc closed this as completed Apr 25, 2014
@sampsyo
Copy link
Member

sampsyo commented Apr 25, 2014

Excellent news! I'm glad this was a comparatively easy fix. Thanks for sticking with it.

@PierreRust
Copy link
Contributor

I'm also getting this problem on ubuntu 14.04 when running tests (in test_art.py) but I don't get how you solved it, could you explain it ? Strangely enough, the artfetch plugin works fine, it's only the tests that fail.

thanks

@dfc
Copy link
Author

dfc commented May 3, 2014

Pierre, I do not understand how/when new versions of responses eggs get created and added to the ecosystem. (Maybe @geigerzaehler or @sampsyo know how this works) Eventually the fix I submitted should get populated but until then you can fix it manually.

I am assuming you did:

$ python setup.py build ; pythonsetup.py test 

and you received an error like:


  File "/home/dfc/0xRepos/Audio/b/test/testall.py", line 42, in suite
    s.addTest(__import__(modname).suite())
  File "/home/dfc/0xRepos/Audio/b/test/test_art.py", line 20, in <module>
    import responses
  File "/home/dfc/0xRepos/Audio/b/responses-0.2.0-py2.7.egg/responses.py", line 36, in <module>
    from requests.packages.urllib3.response import HTTPResponse
ImportError: No module named packages.urllib3.response
(master):dfc@ronin:~/0xRepos/Audio/b$

Take this file: https://raw.githubusercontent.com/dropbox/responses/master/responses.py

and copy it BEETS-SRC-DIR/responses-0.2.0-py2.7.egg/

If you want to see the changes to responses.py: getsentry/responses@712f5c9

Then rerun your tests and everything should work.

$ python setup.py test

----------------------------------------------------------------------
Ran 1127 tests in 116.348s

OK (skipped=5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants