下载地址

https://pypi.org/project/Jinja2/#modal-close

https://pypi.org/project/MarkupSafe/#files

下载源码包

上传解压安装即可(实际操作中,Python 版本是 2.6.6)

tar -zxvf MarkupSafe-1.1.1.tar.gz
cd MarkupSafe-1.1.1
sudo python setup.py install

tar -zxvf Jinja2-2.11.1.tar.gz
cd Jinja2-2.11.1
sudo python setup.py install

安装成功。


实际应用中,发生报错:

$ python demo.py
Traceback (most recent call last):
  File "demo.py", line 4, in <module>
    from jinja2 import Template
  File "/usr/lib/python2.6/site-packages/Jinja2-2.11.1-py2.6.egg/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/usr/lib/python2.6/site-packages/Jinja2-2.11.1-py2.6.egg/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/usr/lib/python2.6/site-packages/Jinja2-2.11.1-py2.6.egg/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/usr/lib/python2.6/site-packages/Jinja2-2.11.1-py2.6.egg/jinja2/filters.py", line 931
    if method not in {"common", "ceil", "floor"}:
                              ^
SyntaxError: invalid syntax

尝试 Python3

sudo yum update
sudo yum install python34

安装 setuptools

下载地址 https://pypi.org/project/setuptools/#files

unzip setuptools-45.2.0.zip
cd setuptools-45.2.0
# 版本太高。。。需要 python3.5+

换个低一点的版本。。。

https://pypi.org/project/setuptools/33.1.1/#files

unzip setuptools-33.1.1.zip

cd setuptools-33.1.1

sudo python3 setup.py install

成功

cd MarkupSafe-1.1.1
sudo python3 setup.py install

有个 warning 
==========================================================================
WARNING: The C extension could not be compiled, speedups are not enabled.
Plain-Python build succeeded.
==========================================================================

cd Jinja2-2.11.1
sudo python3 setup.py install

测试成功。

快速安装脚本:

unzip setuptools-33.1.1.zip
tar -zxvf MarkupSafe-1.1.1.tar.gz
tar -zxvf Jinja2-2.11.1.tar.gz
cd setuptools-33.1.1
sudo python3 setup.py install
cd ../MarkupSafe-1.1.1
sudo python3 setup.py install
cd ../Jinja2-2.11.1
sudo python3 setup.py install