I am using Google Cloud Platform to create a Django based http API, which uses Google's cloud SQL API and Machine Learning API.
I made a django-mysql app on my pc and is able to test it successfully on localhost. I want to deploy this app to Google Cloud.
Following are my relevant files: app.yaml:-
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /static
static_dir: static/
- url: .*
script: mysite.wsgi.application
libraries:
- name: MySQLdb
version: 1.2.5
- name: numpy
version: "1.6.1"
skip_files:
- ^(.*/)?- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^env/.*$
appengine_config.py:-
from google.appengine.ext import vendor
import os
vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
I am getting a 500 error on api home. here. I am getting the following error report on my dashboard:-
Traceback (most recent call last):
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/lib_config.py", line 351, in __getattr__
self._update_configs()
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/lib_config.py", line 287, in _update_configs
self._registry.initialize()
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/lib_config.py", line 160, in initialize
import_func(self._modname)
File "/base/data/home/apps/b~neuralnet-171308/20170628t204601.402294282540056750/appengine_config.py", line 18, in <module>
vendor.add('lib')
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/ext/vendor/__init__.py", line 44, in add
'No such virtualenv or site directory' % path)
ValueError: virtualenv: cannot access lib: No such virtualenv or site directory
Originally the appengine_config.py contained:-
from google.appengine.ext import vendor
vendor.add('lib')
As suggested here, I changed it to the current file.
I deploy my project using gcloud app deploy
. I do not understand how to use gcloud_sql_proxy
for deploying.
I am for sure having a lib
folder in same directory as app.yaml
. I do not know what I am doing wrong. Any help or suggestion is appreciated.
The prior configuration as mentioned here seems to be correct. And as shown in this sample app, try installing dependencies with pip:
pip install -t lib -r requirements.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With