python教程:http://www.ziqiangxuetang.com/django/django-basic.html


python安装下载:  http://www.thinksaas.cn/topics/0/436/436529.html


dgango搭建






2、下载Python3.5的源码包并编译(2.7就可以了,新版本各种坑啊)






wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz



tar xf Python-3.5.0.tgz



cd Python-3.5.0



./configure --prefix=/usr/local



make



make install






mv /usr/bin/python python.bak  --备份旧版本的



ln –s /usr/local/bin/python3 /usr/bin/python









4、运行演示:






python --version



Python 3.5.0








Django安装下载: http://www.runoob.com/django/django-install.html    


安装报错缺少模块:


[root@zw-test-db django-master]# python setup.py install 



Traceback (most recent call last):



  File "setup.py", line 5, in <module>



    from setuptools import find_packages, setup



ImportError: No module named setuptools




安装setools模块








wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26



tar -zxvf setuptools-19.6.tar.gz



cd setuptools-19.6



python setup.py build



python setup.py install






报错:RuntimeError: Compression requires the (missing) zlib module



我们需要在linux中安装zlib-devel包,进行支持。



yum install zlib-devel







2、安装pip



wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb






tar -zxvf pip-8.0.2.tar.gz



cd pip-8.0.2






python setup.py build



python setup.py install






如果没有意外的话,pip安装完成。









测试:






我们使用pip安装一个python3第三方库:python -m pip install paramiko



又报错了!






ImportError: cannot import name 'HTTPSHandler'



应该是缺少openssl的开发环境,我们继续安装






yum install openssl-devel    






  File "/usr/bin/yum", line 30



    except KeyboardInterrupt, e:



                            ^



SyntaxError: invalid syntax






yum竟然报错了









解决的办法是:






vim /usr/bin/yum






#!/usr/bin/python



将上面的语句改为:






#!/usr/bin/python2.6






后面执行yum 就可以使用了






继续重新编译安装python3.5






ok,我们终于完成了整个python3环境的安装。





python环境升级完成后,在安装django




[root@zw-test-db django-master]# python setup.py install 


Download error on https://pypi.python.org/simple/pytz/: unknown url type: https -- Some packages may not be found!



Couldn't find index page for 'pytz' (maybe misspelled?)



Scanning index of all packages (this may take a while)



Reading https://pypi.python.org/simple/



Download error on https://pypi.python.org/simple/: unknown url type: https -- Some packages may not be found!



No local packages or download links found for pytz



error: Could not find suitable distribution for Requirement.parse('pytz')




下载 pytz 安装就行了:  https://pypi.python.org/pypi/pytz/#downloads