I have Google AppEngine SDK installed(at /usr/local/google-appengine), and the toy App can be launched and run with GoogleAppEngine Launcher with no issue.
However, I have some standalone scripts (testpbuf.py) in the app folder that I want to run with
$python testpbuf.py
then I got Python Import errors:
Traceback (most recent call last):
File "testpbuf.py", line 3, in <module>
from google.appengine.api import files
ImportError: No module named appengine.api
The script is trying to import AppEngine API and protorpc modules..
What's going one here? I have the SDK included in my PATH and I have no problem invoking from terminal. Any insights? Thanks a lot!
You need to get all the libraries inside the SDK added to your path. This can be done as follows:
import dev_appserver
dev_appserver.fix_sys_path()
Running code outside of the SDK web-server for things other than tests isn't likely to be that useful to you though ... when it runs on appengine, it has to be via WSGI.
Related
I'm setting up a Flask application on Digitalocean and have Python 3.7 installed and the latest version of Flask. When running the app inside a virtualenv and trying to run the application using python3.7 application.py I get the following error message:
Traceback (most recent call last):
File "application.py", line 11, in <module>
from config import *
ModuleNotFoundError: No module named 'config'
What puzzles me is that config.py is located in the same folder as application.py, and not in a subfolder. I have duplicated the setup on my local machine, also running Python 3.7 and inside a virtualenv, and the importing (and the app) works flawlessly.
I've tried importing "config.py" instead of just "config" but didn't make a difference. I also tried specifying exactly what it should import (instead of using '*') but that didn't make a difference either.
Your thoughts on why it can't find config?
What seems to have been the solution to my problem above was to run the Python shell and add the path to the directory in which config.py is located (even though it's in the same folder as application.py...) by using the following command:
sys.path.append("/path/to/config/")
I am trying to use google task queues in python3, but I am facing some trouble while importing taskqueue library. On issuing the following command
from google.appengine.api import taskqueue
I am getting this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google.appengine'
I have installed Google Cloud SDK and additionally installed 2 more packages as mentioned in the link.
google-cloud-sdk-app-engine-python
google-cloud-sdk-app-engine-python-extras
I have checked the version of gcloud components that has been installed
$ gcloud --version
Google Cloud SDK 206.0.0
alpha 2018.06.18
app-engine-python 1.9.70
app-engine-python-extras 1.9.70
beta 2018.06.18
bq 2.0.34
core 2018.06.18
gsutil 4.32
Why I cannot be able to import taskqueue, Any help would appreciated.
The Task Queue service has limited availability outside of the App Engine standard environment. This issue was reported at, please deploy an App Engine standard app to test this out. You can find sample code at.
I would like to use Google Cloud Storage Client Library Functions.
For that I have to import the cloudstorag. To get the cloudstorage I download Google Cloud Storage client library.
I try to import cloudstorage using python -c "import cloudstorage". I get the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "cloudstorage/__init__.py", line 20, in <module>
from .api_utils import RetryParams
File "cloudstorage/api_utils.py", line 45, in <module>
from google.appengine.api import app_identity
ImportError: No module named google.appengine.api
Am I missing something?
When you execute python -c "import cloudstorage" you're attempting to run a standalone application. But the GCS library you're trying to use is for a (standard environment) GAE application, which cannot be executed as a standalone app, it needs to run in a GAE sandbox (locally that's dev_appserver.py). See GAE: AssertionError: No api proxy found for service "datastore_v3".
And the library needs to be installed inside your GAE app, see Copying a third-party library.
If you're not developing a standard env GAE app and indeed you want to write a standalone one, you're not looking at the right documentation. You need to use a different library than the GAE-specific one(s). See Cloud Storage Client Libraries
You can add this lines, which will add the path of the sdk tools:
import pkgutil
import google
google.__path__ = pkgutil.extend_path(google.__path__, google.__name__)
For unittesting, it could be useful to run in standalone mode.
Looks like gcloud is not installed on your system.
pip install --upgrade gcloud
pip install --upgrade google-api-python-client
I have Google App Engine Python SDK installed and working with the GUI. However, now I am locally trying to test my app using unittest in a virtualenv. Everything is fine until I try to access google.appengine.ext.testbed. How do I access the SDK in this context? My error is included below.
Traceback (most recent call last):
File "tests.py", line 4, in <module>
from google.appengine.ext import testbed
ImportError: No module named google.appengine.ext
update: In further research, I've found that GAE "doesn't play well" with virtualenv. Subsequently, I installed all of my dependencies globally. The issue remains unchanged, so I think we can rule out virtualenv as the culprit.
i've installed python client library for Fusion Tables (here) with all dependencies. But if i try to run oauth_example.py, it aswers me
Traceback (most recent call last): File "./oauth_example.py", line
13, in
from authorization.oauth import OAuth ImportError: No module named authorization.oauth
my python version is 2.7.2+ running on Ubuntu 11.10
and yolk -l
oauth2 - 1.5.211 - active development (/usr/local/lib/python2.7/dist-packages/oauth2-1.5.211-py2.7.egg)
What's wrong?
It seems like you are running the script from the src/samples directory. Try copying the script up one directory and run from the src directory where it can find the authorization/oauth.py module. Or you could include something like this in the top of your python script:
import sys
sys.path.append( '/home/src/python_modules/fusion-tables-client/src')