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.
我有一个纯Python模块,适用于Python 2.6和2.7。而不是将模块放入特定于python版本的路径中,是否可以将库放在Python 2.6和2.7都可以访问的位置?系统是Ubuntu。
2 个解决方案
#1
3
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.
您可以在/ opt之类的位置安装库,然后在/usr/lib/python2.6和/usr/lib/python2.7中创建指向该库的两个软链接。
#2
1
By default, python26 searches for modules in /python2.6/ folders, while python27 looks in /python2.7/ folders.
默认情况下,python26在/python2.6/文件夹中搜索模块,而python27在/python2.7/文件夹中查找。
One way to achieve your goal would be to add to system path another (common) location, by altering PYTHONPATH system variable:
实现目标的一种方法是通过更改PYTHONPATH系统变量将系统路径添加到另一个(公共)位置:
export PYTHONPATH=/common/location
#1
3
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.
您可以在/ opt之类的位置安装库,然后在/usr/lib/python2.6和/usr/lib/python2.7中创建指向该库的两个软链接。
#2
1
By default, python26 searches for modules in /python2.6/ folders, while python27 looks in /python2.7/ folders.
默认情况下,python26在/python2.6/文件夹中搜索模块,而python27在/python2.7/文件夹中查找。
One way to achieve your goal would be to add to system path another (common) location, by altering PYTHONPATH system variable:
实现目标的一种方法是通过更改PYTHONPATH系统变量将系统路径添加到另一个(公共)位置:
export PYTHONPATH=/common/location