How to import google's taskqueue library in python - python

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.

Related

ImportError: No module named 'azure' when running python script on Raspberry Pi

I am trying to send data to the Azure Blob Storage and my first step was to just check the connection by using the sample code I found on the tutorial website:
from azure.storage.blob import BlockBlobService
blob_service = BlockBlobService(account_name, account_key)
blob_service.create_container(
'mycontainername',
public_access=PublicAccess.Blob
)
blob_service.create_blob_from_bytes(
'mycontainername',
'myblobname',
b'<center><h1>Hello World!</h1></center>',
content_settings=ContentSettings('text/html')
)
print(blob_service.make_blob_url('mycontainername', 'myblobname'))
Of course entered the account name and the account key. But I get this error, which I also get when using my own python script so this is a big problem for me:
Traceback (most recent call last):
File "azuretest.py", line 1, in <module>
from azure.storage.blob import BlockBlobService
ImportError: No module named 'azure'
I am a beginner in this topic and I am very lost. Can anyone tell me what to do? Thanks
Installing just the azure-storage library should be sufficient in stead of installing the entire SDK.
pip install azure-storage
Edit
I see you have already done this. The package might not be in your python path. You could try adding
import sys
sys.path.append('/usr/local/lib/python3.6/dist-packages')
at the top of your script (but I am not 100% sure that it will be there on your syste, it is on ubuntu)
or append it to your PYTHONPATH environment variable.

import cloudstorage, ImportError: No module named google.appengine.api

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

Python Import Error when working with GoogleAppEngine

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.

unittests require google.appengine.ext

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.

Ceilometer launch error with ceilometer-collector

I am trying to install Ceilometer for collecting Swift usage data and having a bunch of problems. I am following the link below to install and run Ceilometer for Swift:
http://docs.openstack.org/developer/ceilometer/install/manual.html#installing-manually
I am stuck at step 9 i.e. when I try to launch ceilometer-collector, I get the following error:
**# ceilometer-collector
Traceback (most recent call last):
File "/usr/local/bin/ceilometer-collector", line 6, in <module>
from ceilometer.collector.service import collector
File "/usr/local/lib/python2.7/dist-packages/ceilometer/collector/service.py", line 26, in <module>
from ceilometer.service import prepare_service
File "/usr/local/lib/python2.7/dist-packages/ceilometer/service.py", line 27, in <module>
from ceilometer.openstack.common import gettextutils
File "/usr/local/lib/python2.7/dist-packages/ceilometer/openstack/common/gettextutils.py", line 34, in <module>
from babel import localedata
ImportError: No module named babel**
I have following some questions:
1) What does the option set in step 8.1 in the link above? I mean in /etc/ceilometer/ceilometer.conf, there're no Swift options for *_control_exchange
2) Has anyone successfully installed Ceilometer for Swift? Any step-by-step guide would be immensely helpful as the link above is generic for manual installation.
My configuration is the following:
Management server running the collector, data store, central agent, 2 proxy servers and 3 storage nodes. Everything is running on OpenStack Grizzly on 64-bit Ubuntu 12.04.
The place for more information would be developer documentation http://docs.openstack.org/developer/ceilometer/measurements.html#object-storage-swift
Also check the official project page https://wiki.openstack.org/wiki/Ceilometer
Feel free to join the developer mailing list and posting the feature request if you think more matrix needed.
Hope it helps.
here is a post with trouble shooting for Ceilometer Havana on SLES 11 SP3, http://zqfan.github.io/openstack/2014/03/18/enable-swift-meter-on-suse/
the message "ImportError: No module named babel" means you have not installed the depended python lib.
Swift sample is sent by a ceilometer middleware, which is happen in API request, so I think there is no such swift_control_exchage option

Categories