在无root权限的情况下安装python模块

1.由于学校的集群上以安装了python2.6,现在要安装DeliciousAPI。默认的安装路径在“/usr/local/lib64/python2.6/site-packages”,没有root权限的话就无法安装成功。因此需要指定安装的prefix。

lonfee@node100:~/tools/DeliciousAPI-1.6.7> python setup.py build
/usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running build
running build_py
lonfee@node100:~/tools/DeliciousAPI-1.6.7> python setup.py install --prefix=~/.local
/usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running install
running build
running build_py
running install_lib
byte-compiling /dawnfs/users/lonfee/.local/lib64/python2.6/site-packages/deliciousapi.py to deliciousapi.pyc
running install_egg_info
Removing /dawnfs/users/lonfee/.local/lib64/python2.6/site-packages/DeliciousAPI-1.6.7-py2.6.egg-info
Writing /dawnfs/users/lonfee/.local/lib64/python2.6/site-packages/DeliciousAPI-1.6.7-py2.6.egg-info
lonfee@node100:~/tools/DeliciousAPI-1.6.7> 

2.将指定路径下的lib和bin分别加入环境变量中:

echo "PYTHONPATH=$HOME/.local/lib/python2.6/site-packages" >> .bashrc
echo "export PATH=$HOME/.local/bin:$PATH" >> .bashrc
source .bashrc
这样就实现了在没有root权限的情况下安装python的模块。

3.接下来安装DeliciousAP所依赖的模块BeautifulSoup。

3.1.首先安装setuptools

wget http://pypi.python.org/packages/any/s/setuptools/setuptools-0.6c11-1.src.rpm#md5=27a3fe3a4973c0cc97534bc9e9720c3d
bash setuptools-0.6c11-py2.6.egg --prefix=/dawnfs/users/lonfee/.local/
3.2 安装BeautifulSoup

easy_install --prefix=~/.local BeautifulSoup


总结:在没有root权限的情况下安装软件的方法如下:

1.很多软件都在~目录下有配置文件。如果你只需要更改配置的话,只需更改你个人目录下的配置文件即可。如.bashrc、.vimrc、.screenrc

2.如果你要安装的仅仅是某个软件的模块,如果安装时能指定prefix参数的话,可以安装到home目录下。比如python安装模块,增加新的vim配色文件和插件等。

3.如果不满足1,或者你需要安装一个不同的版本,最好下载源代码,自己编译安装

./configure --prefix=~/path
make
make install

4.如果有必要,更改环境变量。需要注意的是,如果你安装了一个不同于系统已有版本的软件,需要在PATH变量中将新安装软件的bin路径放在原有软件的前面,以确保系统先搜到新安装的软件。

你可能感兴趣的:(c,python,集群,vim,Build,Path)