Install python packages on shared host

你说的曾经没有我的故事 提交于 2019-12-05 02:23:55

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/23428840/install-python-packages-on-shared-host

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