1

I am trying to use google translate api and the api is being called by app engine standard environment. In my development environment dev_appserver.py throwing me the following error ImportError: No module named pkg_resources

I checked the folder, there is no file named "pkg_resources". Did someone face similar kind of issue?

from google.cloud import translate
translate_client = translate.Client()


Traceback (most recent call last):
  File "C:\Users\mdkamalhossain\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle

    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Users\mdkamalhossain\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\lib_config.py", line 351, in __getattr__self._update_configs()

  File "C:\Users\mdkamalhossain\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\lib_config.py", line 287, in _update_configs
    self._registry.initialize()

  File "C:\Users\mdkamalhossain\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\api\lib_config.py", line 160, in initialize
    import_func(self._modname)
  File "C:\my_repo_work\gae-NpsFeedback\appengine_config.py", line 9, in <module>`enter code here`
    from google.cloud import translate
  File "C:\Python27\lib\site-packages\google\cloud\translate.py", line 18, in <module>

    from google.cloud.translate_v2 import __version__
  File "C:\Python27\lib\site-packages\google\cloud\translate_v2\__init__.py", line 18, in <module>
    from pkg_resources import get_distribution

ImportError: No module named pkg_resources
arudzinska
  • 2,582
  • 1
  • 15
  • 26

1 Answers1

0

The traceback indicates that the translate package is installed on your local system, not inside your application:

File "C:\Python27\lib\site-packages\google\cloud\translate.py"

For the standard environment GAE you need to install the library inside your application. From Copying a third-party library:

To use a third-party library that is not on the list of built-in libraries bundled with the runtime:

  1. Create a directory to store your third-party libraries, such as lib/.

    mkdir lib
    
  2. Use pip (version 6 or later) with the -t flag to copy the libraries into the folder you created in the previous step. For example:

    pip install -t lib/ <library_name>
    
Dan Cornilescu
  • 37,297
  • 11
  • 54
  • 89