我想使用不同的django版本。我怎么能创建django virtualenv。请帮忙。
答案 0 :(得分:8)
创建你的virtualenv:
virtualenv myenv
激活那个virtualenv:
source myenv/bin/activate
安装Django:
pip install Django
运行您的项目:
python manage.py runserver
答案 1 :(得分:5)
你需要virtualenv和pip。写在shell中:
对于debian:
apt-get install python-pip
for fedoras(python 2.4,如果你有另一个版本则更改):
yum install python-setuptools
cd /tmpwget http://pypi.python.org/packages/source/p/pip/pip-0.6.3.tar.gz#md5=0602fa9179cfaa98e41565d4a581d98c
tar -xzf pip-0.6.3.tar.gz
cd pip-0.6.3
/usr/bin/python2.4 setup.py install
下:
pip install virtualenv
下:
mkdir enviroments # folder for your different virtual environments
cd enviroments # go to new folder
virtualenv --no-site-packages django1.3 # create folder with new django
cd django1.3 # go to this folder
source bin/activate # activate environment
pip install Django==1.3 # install django 1.3
检查Django版本(也在shell中):
python
import django
django.get_version() # you should get '1.3.0 final'
quit()
现在您可以运行您的服务器了。
退出虚拟环境:
deactivate
删除环境:
rm -r ./bin && virtualenv --clear
例如,您想为您的环境安装MySQLdb模块:
cd enviroments # go to your environments folder
source django1.3/bin/activate # activate it
pip install django1.3/ MySQL-python # install module