0

I've started to use openshift (free account), successing with python. But I need to install some libraries (requests and others). How to do it? I can't find any docs on it...

Forum's info is obscure... I've followed this thread (for third party libs):

Setup.py

from setuptools import setup

setup(name='Igor YourAppName',
  version='1.0',
  description='OpenShift App',
  author='Igor Savinkin',
  author_email='igor.savinkin@gmail.com',
  url='http://www.python.org/sigs/distutils-sig/',
  install_requires=['requests>=2.0.0'], 
 )

WSGI.py

def application(environ, start_response):

ctype = 'text/plain'
if environ['PATH_INFO'] == '/health':
    response_body = "1"
elif environ['PATH_INFO'] == '/env':
    response_body = ['%s: %s' % (key, value)
                for key, value in sorted(environ.items())]
    response_body = '\n'.join(response_body)
else:
    ctype = 'text/html'
    import requests 

see the last line, where I try to import requests. This yields in 500 error:

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Custom python package try

My second try was on this thread:

I've created libs directory in my root dir; then added into wsgi.py:

sys.path.append(os.path.join(os.getenv("OPENSHIFT_REPO_DIR"), "libs"))

and cloned requests into that directory. When I do:

C:\Users\Igor\mypythonapp\libs\requests\requests>git ls-files -c

I get the full list of requests package files... but again, result is 500 error.

Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69
  • When u say librarys, Do you mean installing packets with pip install? – Ricardo Jun 02 '15 at 10:03
  • @Ricardo, I've not been working before with pip. I work with openShift in Win. So it does not recognize `pip` command. Is there a way to make it active in Win? – Igor Savinkin Jun 02 '15 at 12:09
  • possible duplicate of [How do I update Django on Openshift?](http://stackoverflow.com/questions/29028364/how-do-i-update-django-on-openshift) – timo.rieber Jun 02 '15 at 18:46

2 Answers2

0

You should try reading through this section (https://developers.openshift.com/en/python-deployment-options.html) of the Developer Portal which describes how to install dependencies for Pythong applications on OpenShift Online

0

you should use requirements.txt. My requirements.txt is below

admin$ cat requirements.txt
Flask==0.10.1
Requests==2.6.0
kimman
  • 371
  • 2
  • 4