[英]Google Cloud and Appengine Python Package conflict
I'm going through google's appengine tutorials and made the simple example of posting a form ans retrieving the information. 我正在浏览google的appengine教程,并给出了发布表单和检索信息的简单示例 。 Through the tutorial steps I had to install Google Cloud SDK with the appengine libs.
通过教程步骤,我必须使用appengine库安装Google Cloud SDK。
It works fine. 工作正常。
One step forward I pip installed " google-cloud " package, to retrieve a file from Google Storage. 向前迈出了一步,我安装了“ google-cloud ”软件包,以从Google Storage中检索文件。
After installed both google cloud packages,when trying a simple import from my main.py
file as: 在安装
main.py
两个谷歌云程序包之后,尝试从我的main.py
文件中进行以下简单导入:
from google.cloud import storage
I get the error: 我得到错误:
ImportError: No module named google.cloud.storage
Printing google.__path__
I can see the correct path to both packages: 打印
google.__path__
我可以看到两个软件包的正确路径:
[
'/home/xpto/.virtualenvs/dev01/local/lib/python2.7/site-packages/google',
'/home/xpto/.virtualenvs/dev01/lib/python2.7/site-packages/google',
'/home/xpto/Software/google-cloud-sdk/platform/google_appengine/google',
'/home/xpto/projects/testProject01/lib/google'
]
What am I missing here? 我在这里想念什么?
Running python from the terminal in the same virtualenv I can import google.clou packages without problem. 从终端在同一virtualenv中运行python,我可以毫无问题地导入google.clou包。 The error message appears only when I run it using
dev_appserver.py
仅当我使用
dev_appserver.py
运行该错误消息时,该错误消息才会出现
Dan Cornilescu linked to this question which looks it might work. 丹·科尼列斯库(Dan Cornilescu)与这个问题联系在一起,看来这可能有用。
If that doesn't work, you can usually hack import paths to fix it. 如果这不起作用,通常可以破解导入路径来修复它。 I usually don't add the app engine SDK to my virtualenv at all and then just add it manually:
通常,我通常根本不将App Engine SDK添加到我的virtualenv中,然后手动添加它:
import google
google.__path__.append('/path/to/appengine_sdk//google_appengine/google')
sys.path.insert(0, gae_dir) # might not be necessary
import google.appengine # now it's on your import path`
Leave a comment if none of these approaches work. 如果这些方法都不起作用,请发表评论。
The problem was that I installed Google Cloud SDK using the Linux tar.gz package instead of the Debian/Ubuntu installation procedure. 问题是我使用Linux tar.gz软件包而不是Debian / Ubuntu安装过程安装了Google Cloud SDK。
Somehow the tar.gz package messed up my python path. tar.gz包以某种方式弄乱了我的python路径。 Creating a new environment solved.
创建新环境已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.