注:需要配置目錄的地方請不要直接使用例子中的目錄,根據自己的實際目錄進行配置。
1 安裝Python
下載: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/[email protected]/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項目的創建。