Skip to content

ImportError: cannot import name viewkeys #336

Closed

Description

@madelinezec

I have python code that uses mechanize to login to a website. With six==1.4.1 and six==1.10.0, I get this error:

Traceback (most recent call last):
  File "scrapeRecipe.py", line 31, in <module>
    br.select_form(name="aspnetForm")
  File "/Library/Python/2.7/site-packages/mechanize/_mechanize.py", line 619, in select_form
    global_form = self._factory.global_form
  File "/Library/Python/2.7/site-packages/mechanize/_html.py", line 260, in global_form
    self.forms()
  File "/Library/Python/2.7/site-packages/mechanize/_html.py", line 267, in forms
    self._current_forms, self._current_global_form = self._get_forms()
  File "/Library/Python/2.7/site-packages/mechanize/_html.py", line 282, in _get_forms
    if self.root is None:
  File "/Library/Python/2.7/site-packages/mechanize/_html.py", line 247, in root
    response, verify=False))
  File "/Library/Python/2.7/site-packages/mechanize/_html.py", line 145, in content_parser
    from html5lib import parse
  File "/Library/Python/2.7/site-packages/html5lib/__init__.py", line 16, in <module>
    from .html5parser import HTMLParser, parse, parseFragment
  File "/Library/Python/2.7/site-packages/html5lib/html5parser.py", line 2, in <module>
    from six import with_metaclass, viewkeys, PY3
ImportError: cannot import name viewkeys

This appears to similar to this post, except changing the version of six package didn't fix anything.

Activity

  1. jakearchibald commented on Jun 1, 2017

    @jakearchibald

    I'm also getting this error when trying to run Bikeshed

  2. jakearchibald commented on Jun 1, 2017

    @jakearchibald

    I "fixed" it by doing

    sudo pip install --ignore-installed six
  3. yell0wd0g commented on Jun 7, 2017

    @yell0wd0g

    I got the same problem and the same solution, thanks @jakearchibald ! (+@tabatkins FYI)

  4. Martin-Pitt commented on Aug 14, 2017

    @Martin-Pitt

    Thanks @jakearchibald. I had the same problem but when installing Bikeshed for the first time on OSX. Seems to be working now with your solution.

  5. tabatkins commented on Aug 14, 2017

    @tabatkins
  6. added this to the 1.0 milestone on Oct 3, 2017
  7. Chronial commented on Nov 10, 2017

    @Chronial

    This should already be fixed and is basically a duplicate of #301.

  8. willkg commented on Nov 10, 2017

    @willkg
    Contributor

    @Chronial Awesome--thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions