Django CMS 安装 – 自动篇

 

前言

 

django CMS 安装一文我介绍了如何一步一步手动安装django CMS,这篇文章将介绍如何一键自动安装django CMS。

 

djangocms-installer安装

 

具体安装步骤在https://github.com/nephila/djangocms-installer 里有介绍,非常简单,执行一条命令

 

首先创建工作环境

cd C:virtualenvdjangocmsinstaller

virtualenv env

envScriptsactivate

 

安装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

 

 

创建新项目

 

djangocms csblog

csblog是本文的演示项目名

 

安装时报错:

Traceback (most recent call last):

File "c:python27Lib unpy.py", line 162, in _run_module_as_main

"__main__", fname, loader, pkg_name)

File "c:python27Lib unpy.py", line 72, in _run_code

exec code in run_globals

File "C:virtualenvdjangocmsinstallerenvScriptsdjangocms.exe\__main__.py", line 9, in <module>

File "c:virtualenvdjangocmsinstallerenvlibsite-packagesdjangocms_installermain.py", line 33, in execute

verbose=config_data.verbose

File "c:virtualenvdjangocmsinstallerenvlibsite-packagesdjangocms_installerinstall\__init__.py", line 95, in requirements

output = subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)

File "c:python27Libsubprocess.py", line 544, in check_output

raise CalledProcessError(retcode, cmd, output=output)

subprocess.CalledProcessError: Command '[u'pip', u'install', u'-q', u'django-cms>=3.5,<3.6', u'djangocms-admin-style>=1.2,<1.3', u'django-treebeard>=4.0,<5.0', u'https://github.com/divio/djangocms-text-ckeditor/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-file/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-link/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-style/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-googlemap/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-snippet/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-picture/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-video/archive/master.zip?1520402678.71', u'https://github.com/divio/djangocms-column/archive/master.zip?1520402678.71', u'easy_thumbnails', u'django-filer>=1.3', u'Django<2.0', u'pytz', u'django-classy-tags>=0.7', u'html5lib>=0.999999,<0.99999999', u'Pillow>=3.0', u'django-sekizai>=0.9', u'six']' returned non-zero exit status 2

 

从报错的信息看,在安装依赖库时出了问题。当时安装时没能判断哪一步出了问题,所以决定通过源码安装在本地进行调试

 

Fallback版本

在源码调试之前,我尝试了老的版本djangocms-installer==0.9.8,安装是正常的。

 

源码调试

下载 git@github.com:nephila/djangocms-installer.git 到本地,目录 e:Computervirtualenvdjangocms-installer-develop

 

创建virtualenv工作环境并激活

virtualenv env

envScriptsactivate

 

通过源码安装djangocms-installer

python setup.py install

这样djangocms-installer本地安装完成

 

继续尝试执行djangocms csblog,跟pip安装报错相同,所以本地安装和pip安装没有差别!

 

报错是pip安装出错,所以查看源码里跟requirements相关的文件

 

e:computervirtualenvdjangocms-installer-developuildlibdjangocms_installerconfigdata.py

e:computervirtualenvdjangocms-installer-developdjangocms_installerconfigdata.py

e:computervirtualenvdjangocms-installer-developenvlibsite-packagesdjangocms_installer-1.0.0rc1-py2.7.eggdata.py

 

    'plugins-3.4': [

        'djangocms-text-ckeditor>=3.2.1',

        'djangocms-link>=1.8',

        'djangocms-style>=1.7',

        'djangocms-googlemap>=0.5',

        'djangocms-snippet>=1.9',

        'djangocms-video>=2.0',

        'djangocms-column>=1.6',

        'djangocms-file>=2.0,<3.0',

        'djangocms-picture>=2.0,<3.0',

    ],

    'plugins-3.5': [

        'https://github.com/divio/djangocms-text-ckeditor/archive/master.zip?{bust}'

        ''.format(**bust),

        'https://github.com/divio/djangocms-file/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-link/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-style/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-googlemap/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-snippet/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-picture/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-video/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-column/archive/master.zip?{bust}'.format(**bust),

    ],

    'plugins-master': [

        'https://github.com/divio/djangocms-text-ckeditor/archive/master.zip?{bust}'

        ''.format(**bust),

        'https://github.com/divio/djangocms-file/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-link/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-style/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-googlemap/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-snippet/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-picture/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-video/archive/master.zip?{bust}'.format(**bust),

        'https://github.com/divio/djangocms-column/archive/master.zip?{bust}'.format(**bust),

    ],

 

怀疑通过网址的方式会有问题,所以修改以上内容,用plugins-3.4覆盖plugins-master,继续执行djangocms csblog,成功!基本确认跟这个网址安装有关。

 

继续确认,尝试执行

pip install https://github.com/divio/djangocms-file/archive/master.zip

报错

error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

 

对SSL这块不是太了解,所以网上取搜了一些解决方案

https://stackoverflow.com/questions/33972671/downloading-https-pages-with-urllib-error14077438ssl-routinesssl23-get-serve

 

Then it depends on the site. Typical problems with this version of Python is missing support for Server Name Indication (SNI) which was only added to Python 2.7.9. Since lots of sites require SNI today (like everything using Cloudflare Free SSL) I guess this is the problem.

@yak: since TLS 1.2 is also supported with Python 2.7.6. in (K)ubuntu 14.04 my guess is that the upgrade to Python 2.7.10 simply fixed the SNI issue and that's why it worked. 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:virtualenvdjangocmsinstallerenvlibsite-packagespip\_vendor equestspackagesurllib3utilssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.

SNIMissingWarning

 

C:virtualenvdjangocmsinstallerenvlibsite-packagespip\_vendor equestspackagesurllib3utilssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.

InsecurePlatformWarning

 

Python升级完成后,继续尝试执行

pip install https://github.com/divio/djangocms-file/archive/master.zip

 

成功,问题解决。

 

djangocms安装

执行djangocms csblog,即可完成安装。

 

 

关注下方公众号获取更多文章

参考文档

http://docs.django-cms.org/en/release-3.4.x/how_to/install.html

原文地址:https://www.cnblogs.com/2dogslife/p/8508365.html