栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

是否可以在Virtualenv中安装其他版本的Python?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

是否可以在Virtualenv中安装其他版本的Python?

这是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 install

2)安装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.7

4)激活环境

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.>>>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/653190.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号