Python selected libraries
I am running RHEL5 , and i have python 2.4 installed on it.Please dont ask why the native version? My question is that in my home directory i want to install python2.6 with selected packages only and also most importantly i dont want any of the library os or any other which deals with system calls or mail box preferences(sending开发者_如何学Go mail to be prohibited).Is it possible to install a python version with selected libraries only. So now on the system python 2.4 and selected libraries of 2.6 exists
This may not be quite what you're looking for... but the following steps will accomplish something similar to this (if you have root access). The below steps assume you are on i386 architecture.
1) Install Python 2.6 in parallel on your system (requires root). It is available at the EPEL repository:
$ rpm -i http://download.fedora.redhat.com/pub/epel/5/i386/python26-2.6.5-6.el5.i386.rpm
2) Install setuptools by running (again as root):
$ curl http://peak.telecommunity.com/dist/ez_setup.py | python26
3) Install virtualenv (http://pypi.python.org/pypi/virtualenv):
$ easy_install-2.6 virtualenv
4) From your home directory, create a new python environment:
$ cd ~
$ virtualenv --no-site-packages my-env
5) Activate the environment:
$ source my-env/bin/activate
You can now use easy_install to install whatever packages you want, remove anything you don't want from ~/my-env/lib/python26/site-packages, etc.
To let you know you are working in the virtual environment, your prompt will look like this:
[(my-env)you@host ~]$
One thing you have to be careful about is python scripts that start with #!/usr/bin/python, as they will not use the environment version. To ensure that the environment version is used, execute your script like this:
$ python your-script.py
Or you can specifically specify your environment version in your scripts:
#!/home/your-name/my-env/bin/python
Try ActivePython - it installs to an isolated directory (eg: /opt/ActivePython-2.6
), and you can use PyPM to install third-party packages.
精彩评论