virtualenv: cannot access lib: No such virtualenv or site directory
Asked Answered
A

3

6

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.

Allwein answered 28/6, 2017 at 15:46 Comment(1)
Did you find a solution?Grimsby
R
6

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
Roturier answered 17/8, 2017 at 19:31 Comment(2)
Do I run this command on my local machine or do I need to do it on the App Engine instance? If the later, how?Rockrose
This should be marked as a correct answer. Thank you so much! @Rockrose You can run it in your localmachine by dev_appserver.pyFlammable
F
1

Run the below command in root directory of app in cloud shell and deploy.

pip install -t lib -r requirements.txt

Formulism answered 1/6, 2019 at 17:12 Comment(0)
K
-1

Try adding

libraries:
- name: django
  version: "1.11"

to your app.yaml file.

Karolyn answered 7/4, 2018 at 15:57 Comment(1)
This doesn't make any sense. we are here trying to avoid libraries and trying to use the libRavi

© 2022 - 2024 — McMap. All rights reserved.