Install python packages on shared host

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:43:29

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!