这是virtualenv的选项
$ virtualenvYou must provide a DEST_DIRUsage: virtualenv [OPTIONS] DEST_DIROptions: --version show program's version number and exit. -h, --help show this help message and exit. -v, --verbose Increase verbosity. -q, --quietDecrease verbosity. -p PYTHON_EXE, --python=PYTHON_EXE The Python interpreter to use, e.g., --python=python2.5 will use the python2.5 interpreter to create the new environment. The default is the interpreter that virtualenv was installed with (/usr/bin/python) --clear Clear out the non-root install and start from scratch --no-site-packages Don't give access to the global site-packages dir to the virtual environment --unzip-setuptools Unzip Setuptools or Distribute when installing it --relocatable Make an EXISTING virtualenv environment relocatable. This fixes up scripts and makes all .pth files relative --distribute Use Distribute instead of Setuptools. Set environ variable VIRTUALENV_USE_DISTRIBUTE to make it the default --prompt==prompt Provides an alternative prompt prefix for this environment
1)您要做的是将python安装到您也可以编写的目录中。
您可以按照说明进行操作here
。
对于Python 2.7.1
Python source
mkdir ~/srcmkdir ~/.localpythoncd ~/srcwget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgztar -zxvf Python-2.7.1.tgzcd Python-2.7.1make clean./configure --prefix=/home/${USER}/.localpythonmakemake install2)安装virtualenv
virtualenv source
cd ~/srcwget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.5.2.tar.gz#md5=fbcefbd8520bb64bc24a560c6019a73ctar -zxvf virtualenv-1.5.2.tar.gzcd virtualenv-1.5.2/~/.localpython/bin/python setup.py install
3)使用本地python创建一个virtualenv
virtualenv docs
mkdir /home/${USER}/virtualenvscd /home/${USER}/virtualenvs~/.localpython/bin/virtualenv py2.7 --python=/home/${USER}/.localpython/bin/python2.74)激活环境
cd ~/virtualenvs/py2.7/binsource ./activate
5)检查
(py2.7)$ pythonPython 2.7.1 (r271:86832, Mar 31 2011, 15:31:37) [GCC 4.4.5] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> exit()(py2.7)$ deactivate$ pythonPython 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) [GCC 4.4.5] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>



