0

我的系统上有很多与python相关的包,它们对应于不同版本的python。

我认为最佳实践不应该保留这么多版本的 python,但我必须这样做,因为对 linux 的依赖有点复杂。

那么在编写python时如何保持干净的开发环境有什么建议吗?

我的系统中与python相关的详细信息如下:

python
python            python2.4         python2.6         python_bk_24
python2           python26          python2.6-config


[mirror@home project]$ rpm -qa | grep python
python-sqlite-1.1.7-1.2.1
python-setuptools-0.6c5-2.el5
python-pip-0.8-1.el5
dbus-python-0.70-9.el5_4
python-elementtree-1.2.6-5
python-iniparse-0.2.3-4.el5
rpm-python-4.4.2.3-9.el5
libselinux-python-1.33.4-5.7.el5
python-libs-2.4.3-46.el5_8.2
python-devel-2.4.3-46.el5_8.2
ipython-0.8.4-1.el5
audit-libs-python-1.7.7-6.el5_3.3
python-urlgrabber-3.1.0-5.el5
python26-2.6.8-1.el5
python-2.4.3-46.el5_8.2
python26-distribute-0.6.10-4.el5
python26-virtualenv-1.5.1-3.el5
python26-libs-2.6.8-1.el5
python26-devel-2.6.8-1.el5
python-virtualenv-1.7-1.el5
libxml2-python-2.6.26-2.1.15.el5_8.2


[mirror@home project]$ python -V
Python 2.4.3
4

2 回答 2

5

通过virtualenvvirtualenvwrapper包使用虚拟环境。这些使您可以创建独立于各个项目的干净工作区。使用这些工作空间类似于:

mkvirtualenv project1
workon project1
# you are now in the virtual environment for project1- Python packages you
# install (such as with pip) will be installed only in this environment
deactivate project1

一个很好的教程在这里

于 2012-09-08T04:13:37.730 回答
2

如果你想管理多个版本的 Python 和不同的 Pip 包集,我建议使用PythonBrew

Github 站点的README中提供了详细的使用说明。

它类似于 Ruby 的RVM,并带有内置的virtualenv支持。

于 2012-09-08T04:20:29.463 回答