Reputation: 1270
I'm attempting to use the command dev_appserver.py ./
from my application directory, but it's throwing the following error.
ERROR 2016-01-04 04:47:51,421 wsgi.py:263]
Traceback (most recent call last):
File "/Users/Joshua/Scripts/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Joshua/Scripts/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Users/Joshua/Scripts/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/Joshua/Projects/inkren/skritter-api/main.py", line 2, in <module>
from gcloud import datastore
ImportError: No module named gcloud
I'm running a virtualenv that has gcloud installed and also have the gcloud sdk installed with the proper python component. The gcloud library is found when I run python ./main.py
.
# main.py
import webapp2
from gcloud import datastore
class MainPage(webapp2.RequestHandler):
def get(self):
client = datastore.Client(dataset_id='my-project')
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
What I'd like to do is be able to run my code locally in the browser. Is there a way to get dev_appserver.py
to recognize the gcloud library?
Upvotes: 0
Views: 2175
Reputation: 6043
Is using the python development server from gcloud still a problem? I'm successfully using dev_appserver.py
from the terminal. See reference.
Perhaps the install and setup instructions have improved since a year ago. I believe the installation puts the file, dev_appserver.py, in your system path, even on Windows, so it is accessible from the terminal.
Upvotes: 1
Reputation: 10307
I did a bit of research on this, so... Okay, here's what you've got to do.
takes a breath
Head over to this gentleman's GitHub page, and download the package as a zip. https://github.com/dhermes/test-gcloud-on-gae
Now, you need to add some folders/files from his folder into yours to get gcloud
working.
1) Open the application
folder and put the vendor
folder into your root directory. This folder contains the gcloud
package, as well as many others. You can delete the others if you want.
2) Add the appengine_config.py
into your root directory as well. This file tells app engine where your third party packages are.
3) Add darth.py
to your root directory as well. This is just a help file.
Actually, that should do it. This gentleman wrote some scripts for using third party apps with app engine, and they're quite useful. Let me know if your import works after doing that!
I tested it locally and it works perfectly. Basically, any third party python packages work with app engine, as long as there are no other languages within them such as C
.
Upvotes: 0