Skip to content


Install Python modules on a shared host

Sandbox python modules in your home directory

Sandbox python modules in your home directory

Recently had to install a python module for pdf generation reportlab on my shared Dreamhost server. Problem is by default a python module needs to be installed by root so it can be universally available to all users.

The way round this is to append the the install command with the path to your home directory.
python setup.py install --home=~
This will then install the module in /lib/python/ within your home directory. However if you then try to import this module the python interpretor will not find it.

To make python look for the module in the /lib/python/ directory in your home folder as well as in the system directory you need to append it to your python path. The best way to do this is to add it to your .bash_profile. Add the line
export PYTHONPATH=$PYTHONPATH:$HOME/lib/python
.
Then logout and in again to reload your bash_profile or just run the command.
. ./.bash_profile

Posted in geek, python.

Tagged with , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.