I made myself a little module which I happen to use quite a lot. Whenever I need it I simply copy it to the folder in which I want to use it. Since I am lazy I wanted to install it so that I can call it from anywhere, even the interactive prompt. So I read a bit about installing here, and concluded I needed to copy the file over to /usr/local/lib/python2.7/site-packages. That however, doesn’t seem to do anything.
Does anybody know where I need to copy my module for it to work system wide?
Advertisement
Answer
There are methods to install Python modules system-wide. You may want to take a look at distutils. A good tutorial for distutils2 (the current version) can be found here.
You basically have to write a file setup.py
which tells distutils what to do. Then you can simply
python setup.py install
with root permissions to install your module systemwide. There are good and easy examples, plus it’s the cleanest way I can imagine.