简体   繁体   中英

openshift Paas deployment with bottle and python - doesn't find the right place to import from installed modules

I'm trying to deploy a small python bottle application to REdHat openshift platform and I keep getting 500 server error. when I ssh into the app and run python I find out that importing bottle (or every other library I use) fails with importError.

I installed the needed modules in two ways (following a couple of tutorials):

both in the setup.py :

install_requires=['sqlalchemy','bottle','requests']

and by installing a virtenv in the data folder, activating it with:

source virtenv/bin/activate

and pip install bottle sqlalchemy requests

and then editing the wsgi handler entry point :'application' to something like:

import os
here = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'data', 'virtenv/lib/python2.7/site-packages')

virtualenv = os.path.join(here, '..', 'data/virtenv/bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))

from myappname import application

(where myappname contains the actuall bottle application logic) after every change pushing everything with git push to openshift and then the same 500 server error. when ssh to the app and running

python application

I get the import error nothing seems to work, I'll be glad to any help here

edit: when ssh into the app and manually doing

source virtenv/bin/activate

and trying to run python everything works (well at least most of it works) as expected. so for some reason It seems that activate_this.py doesn't behave as expected any clues?

One thing that stood out was the location of your eggs was a bit off. Presumably, that's not a typo and the electrons didn't get scrambled along with the eggs!! :^)

os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'data', 'virtenv/lib/python2.7/site-packages')

Try it with python2.6 instead of the 2.7. I think that should cause the modules to get loaded up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM