Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing python modules that require gcc on shared hosting with no gcc or root access

I'm using Hostgator shared as a production environment and I had a problem installing some python modules, after using:

pip install MySQL-python

pip install pillow

results in:

unable to execute gcc: Permission denied error: command 'gcc' failed with exit status 1

server limitations

  • no root access
  • sudo doesnt work (sudo: effective uid is not 0, is sudo installed setuid root?)
  • no gcc

questions

  1. is there an alternative package for pillow. I want this to use django ImageField. (just like pymysql is an equally capable alternative for mysql-python)

  2. i have modules like mysql-python and pil installed in root, i.e. pip freeze without any virtualenv lists these modules. but i cannot install my other required modules in this root environment and in my virtualenv i cannot install mysql-python and pil. can something be done? can we import/use packages installed in root somehow in a virtualenv?

  3. is hostgator shared only good for PHP and not for python/django webapps. we have limited traffic so we are using hostgator shared. should we avoid hostgator or shared hosting? aren't they good enough for python/django (i had no problems in hosting static/PHP sites ever). are they too many problems and limitations or performance issues (FCGI)? if yes, what are the alternatives?

like image 651
Shubham Badal Avatar asked Oct 05 '14 09:10

Shubham Badal


People also ask

Can I install Python on shared hosting?

Our Shared Hosting packages do not support Python. However, you can use it on a VPS.

How do I install Python libraries without admin rights?

One solution for this is to use executable method in sys package which will return the absolute path of the executable binary for Python against which we can run commands. We add ! (exclamation operator) in front for running it like a shell command from inside notebook, IDE or console.


2 Answers

You can try building wheels on some similar host where gcc is available, copy them to your server and install. But I do not know how much similar hosts should be.

  1. on "similar" host with gcc:

    mkdir /tmp/wheels mkdir /tmp/pip-cache pip wheel --download-cache /tmp/pip-cache -w /tmp/wheels -r requirements.pip

  2. copy wheels to your hosting (I assume that you copy to /tmp/wheels)

  3. install from wheels ignoring index and using wheels dir:

    pip install --download-cache /tmp/pip-cache --find-links=/tmp/wheels --no-index -r requirements-dev.pip

P.S. Maybe you should also copy download-cache to your hosting. I do not remember if this is needed. If this is not needed then you can skip option --download-cache /tmp/pip-cache

like image 143
imposeren Avatar answered Oct 05 '22 00:10

imposeren


  1. you can try to use PIL instead of Pillow (try it but I'm guessing you will probably run into the same compile problem)

  2. when you setup your virtualenv, you can pass it a --system-site-packages flag. See here

  3. there are definitely a lot of alternative services out there- heroku, digital ocean, webfaction etc. Quick plug for PythonAnywhere (I work here)-- we are a PAAS specifically geared towards python frameworks such as Django and come with PIL, mysql-python, and many other python packages preinstalled.

like image 29
conrad Avatar answered Oct 05 '22 00:10

conrad