注:需要配置目录的地方请不要直接使用例子中的目录,根据自己的实际目录进行配置。
下载:python-2.7.12.amd64.msi 下载地址:http://www.python.org/
下载之后直接安装,安装之后进行环境变量的配置。配置如下:
PYTHON_HOME=D:\yingyong\Python27
Path变量中增加:%PYTHON_HOME%;%PYTHON_HOME%\Scripts;
2 安装django
下载:Django-1.10.4.tar.gz 下载地址:https://www.djangoproject.com/download/
下载之后解压。例子解药到D:\Django-1.10.4
运行-->cmd-->到django的解压目录D:\Django-1.10.4(有setup.py的目录)
-->执行命令python setup.py build和python setup.py install
-->添加D:\yingyong\Python27\Lib\site-packages\django\bin到系统环境变量path里面
3 安装Pydev
Help->Install New Software....如图:
Name随便输入个名字
Location输入:http://pydev.org/updates
点击OK,然后照着提示下载安装即可.
4 安装MySQL-python-...exe
下载:MySQL-python-...exe下载地址:http://pypi.python.org/simple/MySQL-python/ 例子使用:MySQL-python-1.2.4b4.win32-py2.7.exe
下载之后直接点击exe文件进行安装即可,如果安装时出现以下错误:
python version 2.7 required,which was not found in the registry
安装PIL-1.1.7.win32-py2.7的时候,不能再注册表中识别出来python2.7
方法:新建一个register.py 文件,把一下代码贴进去,保存
#
# script to register Python 2.0 or later for use with win32all# and other extensions that require Python registry settings#
# written by Joakim Loew for Secret Labs AB / PythonWare#
# source:# http://www.pythonware.com/products/works/articles/regpy20.htm#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
import sys
from _winreg import *
# tweak as necessaryversion = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"pythonkey = "PythonPath"pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)
def RegisterPy(): try:
reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg) except: print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg) print "=== Python", version, "is already registered!"
return
CloseKey(reg) print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
RegisterPy()
进入到存放该文件的目录,执行python register.py即可。
显示“python 2.7 is already registered”
再安装setuptools的时候,就能自动识别出来python2.7了。
win7是 64的原因,在安装python(32位)时,如果选择只为当前用户,以上问题是不会出现的,如果选择所有用户,那就用上面的方法解决吧。
5 eclipse配置
Preferences->Pydev->Interpreter-Python点Auto Config 如图:
2 2
Auto Config之后如图:
点击ok完成配置
6 创建django项目
打开eclipse->File->New->other出现如图:
选择创建django项目然后Next
一直Next到下面界面:
当然你也可以选择其他数据库
注:选择其他数据需安装对应的如MySQL-python-1.2.4b4.win32-py2.7.exe这样的文件
点击finish完成django项目的创建。