Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should version independent python library go?

I have a pure python module that will work for both Python 2.6 and 2.7. Instead of putting the module into the python version specific paths, is it possible to place the library at one location that will be accessed by both Python 2.6 and 2.7? System is Ubuntu.

like image 436
KP. Avatar asked Dec 19 '12 07:12

KP.


People also ask

Where should Python libraries be installed?

Usually the Python library is located in the site-packages folder within the Python install directory, however, if it is not located in the site-packages folder and you are uncertain where it is installed, here is a Python sample to locate Python modules installed on your computer.


2 Answers

You can install the library in one location like /opt and then create two soft links inside /usr/lib/python2.6 and /usr/lib/python2.7 pointing to that library.

like image 85
Atropo Avatar answered Oct 03 '22 19:10

Atropo


By default, python26 searches for modules in /python2.6/ folders, while python27 looks in /python2.7/ folders.

One way to achieve your goal would be to add to system path another (common) location, by altering PYTHONPATH system variable:

export PYTHONPATH=/common/location
like image 29
kaspersky Avatar answered Oct 03 '22 18:10

kaspersky