8

I'm trying to nosetest my little Python script that uses the Google Translate API.
Where do I have to install the API or what do I have to do so nosetest stops telling me

ImportError: No module named apiclient.discovery

The script runs fine, I import it as you would and installed it with pip, but I can't find any info on how to make this work with nosetest.

Any help would be greatly appreciated! :)

LukasKawerau
  • 1,071
  • 2
  • 23
  • 42
  • Do you have multiple Python installs on your machine? – Silas Ray Dec 17 '12 at 17:07
  • I work in a virtualenvwrapper. But I have the API installed outside of that as well. – LukasKawerau Dec 17 '12 at 17:09
  • Drop some code in your nose test to print out the pythonpath it runs with. – Silas Ray Dec 17 '12 at 17:40
  • I'm running into something similar. Here's the module path I get: `/Library/Python/2.7/site-packages/google_api_python_client-1.0-py2.7.egg/apiclient` which seems correct, but `from apiclient.oauth import OAuthCredentials, CredentialsInvalidError` does not work. – Xavi Jan 31 '13 at 22:21
  • 2
    Turns out that upgrading Google API python client from 1.0beta to 1.0 deleted all of its oauth libraries! So to support OAuth 1.0 and 2.0, you need to downgrade back to the beta. The easiest way, I figured out, to do this is to clone the google-api-python-client [Mercurial repo](https://developers.google.com/google-apps/calendar/setup), checkout the appropriate tag, and to install from source. – Xavi Jan 31 '13 at 23:13
  • I followed instructions "Set up a Client Library" here: https://developers.google.com/google-apps/calendar/setup (last update of: Last updated April 30, 2013) and try: from oauth2client.util import _add_query_parameter and get error: ImportError: cannot import name _add_query_parameter – Larry Eitel May 01 '13 at 00:42

2 Answers2

1

The script runs fine, I import it as you would and installed it with pip, but I can't find any info on how to make this work with nosetest.

GAE does not work with pip very well unfortunately. I've encountered a similar problem like this.

What you need to do is copy the modules from your Python's libraries or you can just download them again from their websites, and then paste them directly inside your GAE code. Often, developers create a folder called lib, and add it PYTHONPATH.

Then your nosetests should run.

Games Brainiac
  • 80,178
  • 33
  • 141
  • 199
1

Here I think you can download the tar.gz file at https://pypi.python.org/pypi/apiclient/1.0.2. unpack it and have it installed on your PC.

lonelyjohner
  • 87
  • 1
  • 6