How do I fix packaging issue when generating OpenAPI configuration file? - python-2.7

I am working through the Python Quickstart for Cloud Endpoints Frameworks on App Engine. I try to generate the OpenAPI configuration file by invoking the Endpoints Tool and get this error:
python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname echo.endpoints.[YOUR-PROJECT-ID].cloud.goog
Traceback (most recent call last):
File "lib/endpoints/endpointscfg.py", line 59, in <module>
import _endpointscfg_setup # pylint: disable=unused-import
File "/Users/myName/lab/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_setup.py", line 98, in <module>
_SetupPaths()
File "/Users/myName/lab/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_setup.py", line 94, in _SetupPaths
from google.appengine.ext import vendor
ImportError: No module named appengine.ext
My understanding is that this is some kind of packaging issue? This is issue is discussed here but i am still stuck: Error running endpointscfg.py get_swagger_spec. Any help would be much appreciated.

It turned out to be an issue with my system variable path. Specifically I added:
ENDPOINTS_GAE_SDK="path to google_appengine"

Related

Trouble getting a Python script to execute

I am trying to experiment around with brute forcing Bitcoin Brain Wallets via a Python script I pulled from github. How ever I am unable to get the script to run properly. I cannot get the requirements to install properly and running the script without returns:
Traceback (most recent call last):
File "C:\Users\CCTrollz\Desktop\bruteforce-bitcoin-brainwallet-master\bbb.py", line 7, in <module>
from lib.blockchain import Abe, BlockchainInfo, Insight
File "C:\Users\CCTrollz\Desktop\bruteforce-bitcoin-brainwallet-master\lib\blockchain.py", line 2, in <module>
import requests
ImportError: No module named requests
Github Project

importing google.cloud.datastore not working

I am working in pycharm(in windows) environment.
I am building a website to send query to datastore and display values. I also have data under kind="SpecialTest" that is automatically saved through Node.js. Now I wanted to Query the data from Python.
I installed google-cloud-datastore from command line.
But I can't establish connection to datastore.
My code:
from google.cloud import datastore
cli=datastore.Client(project="My_project_I")
query4= cli.query(kind="SpecialTest").order('Published_at')
print query4
My result:
Internal Server Error
The server has either erred or is incapable of performing the requested operation.
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1272, in default_dispatcher
self.handlers[handler] = handler = import_string(handler)
File "C:\Program Files\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1850, in import_string
return getattr(__import__(module, None, None, [obj]), obj)
File "C:\Users\Harry\workspace\www\app\account.py", line 11, in <module>
from google.cloud import datastore
File "C:\Python27\lib\site-packages\google\cloud\datastore\__init__.py", line 60, in <module>
from google.cloud.datastore.batch import Batch
File "C:\Python27\lib\site-packages\google\cloud\datastore\batch.py", line 24, in <module>
from google.cloud.datastore import helpers
File "C:\Python27\lib\site-packages\google\cloud\datastore\helpers.py", line 23, in <module>
from google.protobuf import struct_pb2
ImportStringError: import_string() failed for 'app.account.UserAccount'. Possible reasons are:
- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;
Original exception:
ImportError: No module named protobuf
Debugged import:
- 'app' found in 'C:\\Users\\Harry\\workspace\\www\\app\\__init__.pyc'.
- 'app.account' not found.
The datastore client library is not supplied by GAE, you need to install/vendor it into your application (different method than for a standalone script).
Alternatively you can use the GAE-specific datastore library - it's actually recommended as it offers some advantages over the general purpose one. From Google App Engine Standard Environment Client Libraries:
Integrate Cloud Datastore with your App Engine Standard Environment
applications by using the App Engine client libraries.
...
Python Google Datastore NDB Client Library
Note: For App Engine applications that are written in Python, the Google Datastore DB Client Library is no longer recommended; use the
Google Datastore NDB Client Library instead.

django celery unit tests with pycharm 'No module named celery'

my tests work fine when my target is a single function (see 'Target' field in the image):
questionator.test_mturk_views.TestReport.submit
However, when I specify my target to include all tests within my questionator app:
questionator
I get this error:
Error ImportError: Failed to import test module:
src.questionator.test_mturk_views Traceback (most recent call last):
File "C:\Python27\Lib\unittest\loader.py", line 254, in _find_tests
module = self._get_module_from_name(name) File "C:\Python27\Lib\unittest\loader.py", line 232, in
_get_module_from_name
import(name) File "C:\Users\Andy\questionator_app\src__init__.py", line 5, in
from .celery import app as celery_app # noqa ImportError: No module named celery
Note that my tests include my settings via 'Environment variables' (see this in the pic too):
DJANGO_SETTINGS_MODULE=questionator_app.settings.development;PYTHONUNBUFFERED=1
The celery documentation mentions a "Using a custom test runner to test with celery" but this is in the now defunct djcelery package. I did though copy/paste/tweak this mentioned test runner and used it as described, but I get the same error.
Unfortunately using CELERY_ALWAYS_EAGER also does not work http://docs.celeryproject.org/en/latest/configuration.html#celery-always-eager
I would appreciate some guidance. With best wishes,
Andy.
with-the-same-problem (most likely me),
I had followed the official tutorial for getting celery working in my project. They advised the below:
Just making the last import explicit solved my problem:
from taskapp.celery import app as celery_app # noqa
I'll see if I can nudge Celery's creators to update their tutorial (pull request).

PyCharm IDE: boto is already installed but got a "No module named boto.cloudfront" importError

I have already got boto installed to my python virtual environment, as shown in the screenshot of my pycharm project.
However I got an ImportError of boto.cloudfront when I run my script from pycharm
ERROR 2015-04-20 00:17:39,590 wsgi.py:263]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/antkong/dev/test/testmain.py", line 7, in <module>
from boto.cloudfront import CloudFrontConnection
ImportError: No module named boto.cloudfront
In the python console, I can import the library just fine:
Any suggestion what can go wrong here?
My project is a Google App Engine project. So even though boto is installed locally, it is not visible to my code within my Google App Engine project
My solution is to copy the boto and all dependency into a lib subdirectory and then add it to the sys.path

Amazon Beanstalk CLI Error: lib.utility, no module found

I am trying to follow the directions given for getting a Django application up on Amazon Beanstalk, and when I run the eb init command, I receive the following error:
Traceback (most recent call last):
File "/usr/local/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python2.7/eb", line 17, in <module>
from scli import core
File "/usr/local/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python2.7/scli/core.py", line 24, in <module>
from scli import command, cli_parse, config_file, prompt
File "/usr/local/AWS-ElasticBeanstalk-CLI-2.4.0/eb/linux/python2.7/scli/command.py", line 16, in <module>
from lib.utility import misc
ImportError: No module named utility
I am really unsure as to what I am failing to do or missing...
So it turns out that somewhere along this very terrible journey I downloaded the AWS Beanstalk CLI version 2.4, when I needed 2.6, in case anyone else makes this same clumsy mistake.