Skip to content

Cannot run sample code #63

@ShaneOH

Description

@ShaneOH

Hey @mircealungu -- I cloned the repo and ran the steps for setup. I then created a test.py file in the project root directory as shown:

test.py

from python_translators.translators.google_translator import GoogleTranslator
gt = GoogleTranslator(source_language='nl', target_language='en', key='xxx')

gt.translate('leer')

However, this fails to run with the following:

Traceback (most recent call last):
  File "/home/shane/python-translators/test.py", line 2, in <module>
    gt = GoogleTranslator(source_language='nl', target_language='en', key='xxx')
  File "/home/shane/python-translators/python_translators/translators/google_translator.py", line 38, in __init__
    self.translation_service = build('translate', 'v2', developerKey=key, cache_discovery=False)
  File "/home/shane/.local/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/shane/.local/lib/python3.10/site-packages/googleapiclient/discovery.py", line 267, in build
    requested_url = uritemplate.expand(discovery_url, params)
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/api.py", line 33, in expand
    return URITemplate(uri).expand(var_dict, **kwargs)
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/template.py", line 132, in expand
    return self._expand(_merge(var_dict, kwargs), False)
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/template.py", line 97, in _expand
    expanded.update(v.expand(expansion))
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/variable.py", line 338, in expand
    expanded = expansion(name, value, opts['explode'], opts['prefix'])
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/variable.py", line 278, in _string_expansion
    if dict_test(value) or tuples:
  File "/home/shane/.local/lib/python3.10/site-packages/uritemplate/variable.py", line 363, in dict_test
    return isinstance(value, (dict, collections.MutableMapping))
AttributeError: module 'collections' has no attribute 'MutableMapping'

Has some version changing in the last couple years broken this library, or am I doing something wrong? Are you able to install and run this from scratch still?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions