问题描述
我觉得我一切设置正确.我遵循了这些说明.
I feel I set everything up correctly. I followed these instructions.
并从tar文件中安装.
and installed from the tar file.
我的主目录中有一个文件夹"gsutil",现在.我完成了配置以将我的应用设置为oauth2,并能够从命令行调用gsutil.要使用gsutil和Google App Engine,我在主目录的.bashrc文件中添加了以下几行,并提供了该文件的来源:
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
但是,当我尝试通过以下任一方式导入python脚本时:
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
我收到如下错误:
ImportError: No module named gslib.third_party.oauth2_plugin
我在某个地方错过了一步吗?谢谢
Did I miss a step somewhere? Thanks
这是(','.join(sys.path))的输出:
Here is the output of (','.join(sys.path)):
import sys; print(', '.join(sys.path))
我可以从命令行导入模块,但是不能从我的Google App Engine应用程序中导入模块.这是使用python -v
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
/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仅在命令行中使用.如果要从Appengine应用程序中与云存储进行交互,则应使用云存储客户端库: https://developers.google.com/appengine/docs/java/googlecloudstorageclient/
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/
这篇关于无法导入gsutil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!