質問

I feel I set everything up correctly. I followed these instructions.

and installed from the tar file.

My home directory has a folder "gsutil" now. I ran through the configuration to set my app up for oauth2, and am able to call gsutil from the command line. To use gsutil and Google App Engine, I added the following lines to the .bashrc file in my Home directory and sourced it:

export PATH=$PATH:$HOME/google_appengine
export PATH=${PATH}:$HOME/gsutil
export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/third_party/boto:$HOME/gsutil

However, when I try to import in my python script by either:

import gsutil

Or something like this (straight from the documentation).

from gslib.third_party.oauth2_plugin import oauth2_plugin

I get errors like:

ImportError: No module named gslib.third_party.oauth2_plugin

Did I miss a step somewhere? Thanks

EDIT:

Here is the output of (','.join(sys.path)):

import sys; print(', '.join(sys.path))

, /usr/local/lib/python2.7/dist-packages/setuptools-1.4.1-py2.7.egg, /usr/local/lib/python2.7/dist-packages/pip-1.4.1-py2.7.egg, /usr/local/lib/python2.7/dist-packages/gsutil-3.40-py2.7.egg, /home/[myname], /home/[myname]/gsutil/third_party/boto, /home/[myname]/gsutil, /usr/lib/python2.7, /usr/lib/python2.7/plat-linux2, /usr/lib/python2.7/lib-tk, /usr/lib/python2.7/lib-old, /usr/lib/python2.7/lib-dynload, /usr/local/lib/python2.7/dist-packages, /usr/lib/python2.7/dist-packages, /usr/lib/python2.7/dist-packages/PIL, /usr/lib/python2.7/dist-packages/gst-0.10, /usr/lib/python2.7/dist-packages/gtk-2.0, /usr/lib/python2.7/dist-packages/ubuntu-sso-client, /usr/lib/python2.7/dist-packages/ubuntuone-client, /usr/lib/python2.7/dist-packages/ubuntuone-control-panel, /usr/lib/python2.7/dist-packages/ubuntuone-couch, /usr/lib/python2.7/dist-packages/ubuntuone-installer, /usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol

EDIT 2:

I can import the module from the command line, but can't from within my Google App Engine app.. Here is the first line of the output using python -v

import gsutil

/home/adrian/gsutil/gsutil.pyc matches /home/adrian/gsutil/gsutil.py

But when I try to import it from an app, I get this message:

import gsutil
ImportError: No module named gsutil
役に立ちましたか?

解決

gsutil is intended to only be used from the command line. If you want to interact with cloud storage from within an appengine application you should be using the cloud storage client library: https://developers.google.com/appengine/docs/java/googlecloudstorageclient/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top