6

I would like to know if it is possible to install (without using shell - I don't have any permissions to use command line) python packages on a shared host. (Do not ask to change host provider)

Also, on that host is installed Python and Django and I would like to install : https://pypi.python.org/pypi/xlwt on server.

Is that possible?

Shmwel
  • 1,697
  • 5
  • 26
  • 43
  • 1
    you should just ask the host - if it is a common package they may do it for you – acutesoftware May 02 '14 at 13:16
  • I know that. I just wondered if I can do without involving them. – Shmwel May 02 '14 at 13:19
  • xlwt doesn't need to be installed system-wide. Just place the xlwt folder into your Django project as you'd do with an app and use it from there. – Phillip May 02 '14 at 13:37
  • You're wrong. http://www.simplistix.co.uk/presentations/python-excel.pdf#Installation. You still need to execute cmd lines – Shmwel May 02 '14 at 14:33
  • It should (and does here). How do you try import xlwt? Maybe you placed it outside of the python path? (In a django environment you'd typically have to `import projectname.xlwt` or use a relative import like `from . import xlwt`. Also see `sys.path`.) – Phillip May 03 '14 at 11:00

2 Answers2

15

I don't think it is possible without SSH. For what it's worth, I have GoDaddy deluxe shared hosting on Linux and I was able to install Python as follows:

Set up a new directory in /home/"your username":

mkdir ~/python27
cd ~/python27

Download and unpack Python files:

wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
tar -xzvf Python-2.7.12.tgz
find ~/python27 -type d -exec chmod 755 {} \;
cd Python-2.7.12

Configure and install Python:

./configure --prefix=$HOME/python27
make
make install

Update your default Python path by modifying your bash_profile file:

vi ~/.bash_profile

Add these lines to bash_profile:

# Python 2.7
export PATH="$HOME/python27/bin:$PATH"

Confirm that the changes took place:

python -V #old version
source ~/.bashrc
python -V #new version

Install easy_setup:

wget https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py

Quit SSH, log in again, and install pip:

easy_install pip

You can now add libraries as required. You can access the new version in your python applications with:

#! /home/"your username"/python27/Python-2.7.12/python

The following links were all helpful, but I needed to combine various steps for it to work for me:

http://geeksta.net/geeklog/python-shared-hosting/

https://www.godaddy.com/garage/tech/config/how-to-install-and-configure-python-on-a-hosted-server/

https://gist.github.com/BigglesZX/1610950

ezChx
  • 4,024
  • 1
  • 19
  • 16
2

Though this is an old question, I bumped into the same problem.

You normally can not install packages for Python easily. There is however a nice solution. Virtualenv creates a local instance of Python, and after installing virtualenv, you can install packages locally in your account.

jcoppens
  • 5,306
  • 6
  • 27
  • 47