6

I'm trying to install python packages on OpenShift but I see a dearth of pages about the best way to do this. Can someone please suggest the best way of getting on say oauth2 and simplejson. I've tried including these in the setup.py, but I have no idea whether these are actually available or I'll have to upload and point to the path. How can I do this?

disruptive
  • 5,687
  • 15
  • 71
  • 135

2 Answers2

11

Did you install rhc (made by OpenShift.com) ?
If not then see on OpenShift.com: Installing OpenShift RHC Client Tools

Now you can access server with rhc

rhc ssh

and then you can do as always:

checking python version (with big V)

python -V

checking pip version (with big V)

pip -V

checking installed modules

pip freeze

searching module

pip search simplejson

pip search json | sort # sorted result

installing new module

pip install simplejson

and other linux/bash functions

ls
ls -al
echo "hello world"
cd folder_name
mkdir new_folder_name
chmod +x filename
cat filename
grep 'hello' */*.py
history
nano filename
for x in */* ; do echo $x ; done
furas
  • 134,197
  • 12
  • 106
  • 148
  • Thanks. I've managed to get some of the packages required installed although there seems to be an issue getting MYSQL-python installed. I get the following: ImportError: No module named 'ConfigParser' and yet I cannot manually include ConfigParser to avoid this. – disruptive Jul 05 '14 at 07:35
  • In Python3 it named `configparser` - lowercase. Try `python -i` and `import configparser` - you don't get error. And that's why `MYSQL-python` has problem. I prefer `Postgres` so I have no problem with this. But on `PythonAnywhere.org` I had to use `MySQL` and they show how to install external package with `pip` - https://www.pythonanywhere.com/wiki/UsingMySQL. Maybe it will work for you. – furas Jul 05 '14 at 13:32
  • I've installed rhc and git on local machine (Win 8). But python is on the server, not locally (and packages I need on server). So neither `python -V` no 'pip -V' work. What to do? – Igor Savinkin May 08 '15 at 10:12
  • Connect to server using `rhc ssh` and run `python -V` on server. – furas May 08 '15 at 18:03
2

Trying to install Python libraries via pip always results in OSError: [Errno 13] Permission denied errors for me. Not sure if this is a change in OpenShift behavior or a some misconfiguration on my part. For anyone else who has issues installing via pip, easy_install consistently works for me (at least with the Flask cartridge):

[appname-domain.rhcloud.com ]\> easy_install simplejson
Searching for simplejson
Best match: simplejson 3.2.0
Adding simplejson 3.2.0 to easy-install.pth file

Using /opt/rh/python27/root/usr/lib64/python2.7/site-packages
Processing dependencies for simplejson
Finished processing dependencies for simplejson
Alex Glover
  • 759
  • 5
  • 15