正文共:6775字3图
预计阅读时间:17分钟
在django CMS安装一文我介绍了如何一步一步手动安装django CMS,这篇文章将介绍如何一键自动安装django CMS。
01
djangocms-installer 安装
具体安装步骤在https://github.com/nephila/djangocms-installer里有介绍,非常简单,执行一条命令
首先创建工作环境
cd C:\virtualenv\djangocmsinstaller
virtualenv env
env\Scripts\activate
安装djangocms-installer
pip install djangocms-installer
检查安装的库
pip freeze
dj-database-url==0.5.0
djangocms-installer==1.0.0
pytz==2018.3
six==1.11.0
tzlocal==1.5.1
02
创建新项目
djangocms csblog
csblog是本文的演示项目名
安装时报错:
Traceback (most recent call last):
File"c:\python27\Lib\runpy.py", line 162, in _run_module_as_main
"__main__",fname, loader, pkg_name)
File"c:\python27\Lib\runpy.py", line 72, in _run_code
execcode in run_globals
File"C:\virtualenv\djangocmsinstaller\env\Scripts\djangocms.exe\__main__.py",line 9, in
File"c:\virtualenv\djangocmsinstaller\env\lib\site-packages\djangocms_installer\main.py",line 33, in execute
verbose=config_data.verbose
File"c:\virtualenv\djangocmsinstaller\env\lib\site-packages\djangocms_installer\install\__init__.py",line 95, in requirements
output= subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)
File"c:\python27\Lib\subprocess.py", line 544, in check_output
raiseCalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '[u'pip', u'install',u'-q', u'django-cms>=3.5,=1.2,=4.0,=1.3', u'Django=0.7', u'html5lib>=0.999999,=3.0', u'django-sekizai>=0.9', u'six']'returnednon-zero exit status 2
从报错的信息看,在安装依赖库时出了问题。当时安装时没能判断哪一步出了问题,所以决定通过源码安装在本地进行调试
03
源码调试
在源码调试之前,我尝试了老的版本djangocms-installer==0.9.8,安装是正常的。
创建virtualenv工作环境并激活
virtualenv env
env\Scripts\activate
通过源码安装djangocms-installer
python setup.py install
这样djangocms-installer本地安装完成
继续尝试执行djangocms csblog,跟pip安装报错相同,所以本地安装和pip安装没有差别!
报错是pip安装出错,所以查看源码里跟requirements相关的文件
e:\computer\virtualenv\djangocms-installer-develop\build\lib\djangocms_installer\config\data.py
e:\computer\virtualenv\djangocms-installer-develop\djangocms_installer\config\data.py
e:\computer\virtualenv\djangocms-installer-develop\env\lib\site-packages\djangocms_installer-1.0.0rc1-py2.7.egg\data.py
怀疑通过网址的方式会有问题,所以修改以上内容,用plugins-3.4覆盖plugins-master,继续执行djangocms csblog,成功!基本确认跟这个网址安装有关。
继续确认,尝试执行
pip install https://github.com/divio/djangocms-file/archive/master.zip
报错
对SSL这块不是太了解,所以网上取搜了一些解决方案
https://stackoverflow.com/questions/33972671/downloading-https-pages-with-urllib-error14077438ssl-routinesssl23-get-serve
Then it depends on thesite. Typical problems with this version of Python is missing support forServerName Indication (SNI)which wasonly added to Python 2.7.9. Since lots of sites require SNI today (likeeverything using Cloudflare Free SSL) I guess this is the problem.
@yak: sinceTLS 1.2 is also supported with Python 2.7.6. in (K)ubuntu 14.04 my guess isthat the upgrade to Python 2.7.10 simply fixed the SNI issue and that's why itworked. Nevertheless, it counts that it works.
从以上stackover问题描述可以看到他们的解决方案是升级python到2.7.10,当前我的python版本是2.7.3,而且我一直碰到SNIMissingWarning的问题,所以我猜测这两个问题相关,于是将我的python升级到了2.7.10 (注: Python2.7.10是一个bug fix release )
附带信息:下面是我执行pip install操作时一直碰到的两个告警
C:\virtualenv\djangocmsinstaller\env\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318:SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject NameIndication) extension to TLS is not available on this platform. This may causethe server to present an incorrect TLS certificate, which can cause validationfailures. You can upgrade to a newer version of Python to solve this. For moreinformation, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
C:\virtualenv\djangocmsinstaller\env\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122:InsecurePlatformWarning: A true SSLContext object is not available. Thisprevents urllib3 from configuring SSL appropriately and may cause certain SSLconnections to fail.You can upgrade to a newer versionof Python to solve this.For more information, seehttps://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Python升级完成后,继续尝试执行
pip install https://github.com/divio/djangocms-file/archive/master.zip
成功,问题解决。
03
djangocms 安装
执行djangocms csblog,即可完成安装。
领取专属 10元无门槛券
私享最新 技术干货