设为首页 收藏本站
查看: 776|回复: 0

[经验分享] Python flask 框架搭建

[复制链接]

尚未签到

发表于 2018-8-8 10:05:48 | 显示全部楼层 |阅读模式
  系统环境:CentOS7,Python版本:2.7.5

  •   检查是否安装了virtualenv
      virtualenv -version
  没有显示版本信息,说明没有安装virtualenv.
  安装virtualenv的作用是使用程序运行能使用虚拟环境。
  [root@localhost ~]# yum install python-virtualenv
  Loaded plugins: fastestmirror
  base                                                                                                                                             | 3.6 kB  00:00:00
  epel/x86_64/metalink                                                                                                                             | 5.2 kB  00:00:00
  epel                                                                                                                                             | 4.7 kB  00:00:00
  extras                                                                                                                                           | 3.4 kB  00:00:00
  updates                                                                                                                                          | 3.4 kB  00:00:00
  (1/3): extras/7/x86_64/primary_db                                                                                                                | 130 kB  00:00:00
  (2/3): epel/x86_64/updateinfo                                                                                                                    | 848 kB  00:00:10
  (3/3): epel/x86_64/primary_db                                                                                                                    | 6.1 MB  00:00:17
  Loading mirror speeds from cached hostfile
  * base: mirrors.aliyun.com
  * epel: mirrors.ustc.edu.cn
  * extras: mirrors.btte.net
  * updates: mirrors.aliyun.com
  Resolving Dependencies
  --> Running transaction check
  ---> Package python-virtualenv.noarch 0:1.10.1-4.el7 will be installed
  --> Processing Dependency: python-setuptools for package: python-virtualenv-1.10.1-4.el7.noarch
  --> Running transaction check
  ---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
  --> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
  --> Running transaction check
  ---> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 will be installed
  --> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
  --> Running transaction check
  ---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
  --> Finished Dependency Resolution
  Dependencies Resolved
  ========================================================================================================================================================================
  Package                                                     Arch                           Version                                  Repository                    Size
  ========================================================================================================================================================================
  Installing:
  python-virtualenv                                           noarch                         1.10.1-4.el7                             base                         1.2 M
  Installing for dependencies:
  python-backports                                            x86_64                         1.0-8.el7                                base                         5.8 k
  python-backports-ssl_match_hostname                         noarch                         3.4.0.2-4.el7                            base                          12 k
  python-setuptools                                           noarch                         0.9.8-7.el7                              base                         397 k
  Transaction Summary
  ========================================================================================================================================================================
  Install  1 Package (+3 Dependent packages)

  Total download>
  Installed>  Is this ok [y/d/N]: y
  Downloading packages:
  (1/4): python-backports-1.0-8.el7.x86_64.rpm                                                                                                     | 5.8 kB  00:00:00
  (2/4): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm                                                                              |  12 kB  00:00:00
  (3/4): python-setuptools-0.9.8-7.el7.noarch.rpm                                                                                                  | 397 kB  00:00:00
  python-virtualenv-1.10.1-4.el7 FAILED
  http://mirrors.nju.edu.cn/centos/7.4.1708/os/x86_64/Packages/python-virtualenv-1.10.1-4.el7.noarch.rpm: [Errno 12] Timeout on http://mirrors.nju.edu.cn/centos/7.4.1708/os/x86_64/Packages/python-virtualenv-1.10.1-4.el7.noarch.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
  Trying other mirror.
  (4/4): python-virtualenv-1.10.1-4.el7.noarch.rpm                                                                                                 | 1.2 MB  00:00:01
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                                                                                                    49 kB/s | 1.6 MB  00:00:34
  Running transaction check
  Running transaction test
  Transaction test succeeded
  Running transaction
  Installing : python-backports-1.0-8.el7.x86_64                                                                                                                    1/4
  Installing : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                             2/4
  Installing : python-setuptools-0.9.8-7.el7.noarch                                                                                                                 3/4
  Installing : python-virtualenv-1.10.1-4.el7.noarch                                                                                                                4/4
  Verifying  : python-virtualenv-1.10.1-4.el7.noarch                                                                                                                1/4
  Verifying  : python-setuptools-0.9.8-7.el7.noarch                                                                                                                 2/4
  Verifying  : python-backports-1.0-8.el7.x86_64                                                                                                                    3/4
  Verifying  : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch                                                                                             4/4
  Installed:
  python-virtualenv.noarch 0:1.10.1-4.el7
  Dependency Installed:
  python-backports.x86_64 0:1.0-8.el7            python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7            python-setuptools.noarch 0:0.9.8-7.el7
  Complete!
  2.创建目录/flask
  [root@localhost ~]# cd /flask/
  3.[root@localhost flask]# virtualenv venv
  [root@localhost flask]# virtualenv venv
  New python executable in venv/bin/python
  Installing Setuptools..............................................................................................................................................................................................................................done.
  Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
  4.激活创建的虚拟环境
  [root@localhost flask]# source venv/bin/activate
  屏幕回显出现变化
  (venv)[root@localhost flask]#
  5.安装flask
  (venv)[root@localhost flask]# pip install flask
  Downloading/unpacking flask
  Downloading Flask-0.12.2.tar.gz (548kB): 548kB downloaded
  Running setup.py egg_info for package flask
  warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_themes'
  Downloading/unpacking Werkzeug>=0.7 (from flask)
  Downloading Werkzeug-0.12.2.tar.gz (1.2MB): 1.2MB downloaded
  Running setup.py egg_info for package Werkzeug
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_themes'
  warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
  warning: no previously-included files matching '__pycache__' found anywhere in distribution
  warning: no previously-included files matching '*.so' found anywhere in distribution
  warning: no previously-included files matching '*.pyd' found anywhere in distribution
  Downloading/unpacking Jinja2>=2.4 (from flask)
  Downloading Jinja2-2.10.tar.gz (261kB): 261kB downloaded
  Running setup.py egg_info for package Jinja2
  warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  no previously-included directories found matching 'docs/_build'
  Downloading/unpacking itsdangerous>=0.21 (from flask)
  Downloading itsdangerous-0.24.tar.gz (46kB): 46kB downloaded
  Running setup.py egg_info for package itsdangerous
  warning: no previously-included files matching '*' found under directory 'docs/_build'
  Downloading/unpacking click>=2.0 (from flask)
  Downloading click-6.7.tar.gz (279kB): 279kB downloaded
  Running setup.py egg_info for package click
  warning: no previously-included files matching '*.pyc' found under directory 'docs'
  warning: no previously-included files matching '*.pyo' found under directory 'docs'
  warning: no previously-included files matching '*.pyc' found under directory 'tests'
  warning: no previously-included files matching '*.pyo' found under directory 'tests'
  warning: no previously-included files matching '*.pyc' found under directory 'examples'
  warning: no previously-included files matching '*.pyo' found under directory 'examples'
  no previously-included directories found matching 'docs/_build'
  Downloading/unpacking MarkupSafe>=0.23 (from Jinja2>=2.4->flask)
  Downloading MarkupSafe-1.0.tar.gz
  Running setup.py egg_info for package MarkupSafe
  Installing collected packages: flask, Werkzeug, Jinja2, itsdangerous, click, MarkupSafe
  Running setup.py install for flask
  warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_themes'
  Installing flask script to /flask/venv/bin
  Running setup.py install for Werkzeug
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'docs/_themes'
  warning: no previously-included files matching '*.py[cdo]' found anywhere in distribution
  warning: no previously-included files matching '__pycache__' found anywhere in distribution
  warning: no previously-included files matching '*.so' found anywhere in distribution
  warning: no previously-included files matching '*.pyd' found anywhere in distribution
  Running setup.py install for Jinja2
  warning: no previously-included files matching '*.py[co]' found anywhere in distribution
  no previously-included directories found matching 'docs/_build'
  File "/flask/venv/lib/python2.7/site-packages/jinja2/asyncfilters.py", line 7
  async def auto_to_seq(value):
  ^
  SyntaxError: invalid syntax
  File "/flask/venv/lib/python2.7/site-packages/jinja2/asyncsupport.py", line 22
  async def concat_async(async_gen):
  ^
  SyntaxError: invalid syntax
  Running setup.py install for itsdangerous
  warning: no previously-included files matching '*' found under directory 'docs/_build'
  Running setup.py install for click
  warning: no previously-included files matching '*.pyc' found under directory 'docs'
  warning: no previously-included files matching '*.pyo' found under directory 'docs'
  warning: no previously-included files matching '*.pyc' found under directory 'tests'
  warning: no previously-included files matching '*.pyo' found under directory 'tests'
  warning: no previously-included files matching '*.pyc' found under directory 'examples'
  warning: no previously-included files matching '*.pyo' found under directory 'examples'
  no previously-included directories found matching 'docs/_build'
  Running setup.py install for MarkupSafe
  building 'markupsafe._speedups' extension
  gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o
  unable to execute gcc: No such file or directory
  ==========================================================================
  WARNING: The C extension could not be compiled, speedups are not enabled.
  Failure information, if any, is above.
  Retrying the build without the C extension now.
  ==========================================================================
  WARNING: The C extension could not be compiled, speedups are not enabled.
  Plain-Python installation succeeded.
  ==========================================================================
  Successfully installed flask Werkzeug Jinja2 itsdangerous click MarkupSafe
  Cleaning up...
  #有时间研究为什么会出现这么多WARNING
  6.验证是否安装成功。
  (venv)[root@localhost flask]# python
  Python 2.7.5 (default, Aug  4 2017, 00:39:18)
  [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import flask
  >>> exit()

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-548519-1-1.html 上篇帖子: python-anaconda 下篇帖子: Python添加tab自动补全及命令历史功能。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表