前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Flask第三篇——安装Flask

Flask第三篇——安装Flask

作者头像
孟船长
发布2018-05-18 18:36:53
1.2K0
发布2018-05-18 18:36:53
举报
文章被收录于专栏:自动化测试实战

再次和大家强调一下,如果你想工资有所突破,光靠那些测试知识船长个人认为局限还是比较大的,学点开发的知识对你的帮助很大。船长会坚持写下去,一起学习的机会只有这么一次,多余的话我就不说了。


现在我们来安装Flask:

Windows系统安装Flask

如果你的系统是Windows,那安装起来非常方便——pip install flask

Mac系统安装Flask

Mac安装Flask一般为了不影响Python本身的功能会先下载一个虚拟环境,命令如下:

  • 第一步:macbookdeMBP-2:~ macbook$ sudo easy_install virtualenv
  • 第二步:macbookdeMBP-2:~ macbook$ virtualenv venv

会看到:

代码语言:javascript
复制
New python executable in /Users/macbook/venv/bin/python
Installing setuptools, pip, wheel...done.
  • 第三步:激活虚拟环境

macbookdeMBP-2:~ macbook$ pwd

/Users/macbook

macbookdeMBP-2:~ macbook$ cd /Users/macbook

macbookdeMBP-2:~ macbook$ ls

Applications Downloads Music PycharmProjects

Desktop Library Pictures VirtualBox VMs

Documents Movies Public venv

macbookdeMBP-2:~ macbook$ cd venv

macbookdeMBP-2:venv macbook$ ls

bin lib

include pip-selfcheck.json

macbookdeMBP-2:venv macbook$ cd bin

macbookdeMBP-2:bin macbook$ ls

activate easy_install-2.7 python-config

activate.csh pip python2

activate.fish pip2 python2.7

activate_this.py pip2.7 wheel

easy_install python

macbookdeMBP-2:bin macbook$ source activate

至此,虚拟机已经激活

  • 第四步:在虚拟环境下安装Flask

先回到venv目录下,然后安装

(venv) macbookdeMBP-2:bin macbook$ cd ..

(venv) macbookdeMBP-2:venv macbook$ cd..

(venv) macbookdeMBP-2:~ macbook$ ls

Applications Downloads Music PycharmProjects

Desktop Library Pictures VirtualBox VMs

Documents Movies Public venv

(venv) macbookdeMBP-2:~ macbook$ cd venv

(venv) macbookdeMBP-2:venv macbook$ ls

bin lib

include pip-selfcheck.json

(venv) macbookdeMBP-2:venv macbook$ pip install flask

安装后看到:

代码语言:javascript
复制
Collecting flask
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 134kB/s 
Collecting Jinja2>=2.4 (from flask)
  Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 214kB/s 
Collecting Werkzeug>=0.7 (from flask)
  Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
    100% |████████████████████████████████| 327kB 211kB/s 
Collecting click>=2.0 (from flask)
  Downloading click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 233kB/s 
Collecting itsdangerous>=0.21 (from flask)
  Downloading itsdangerous-0.24.tar.gz (46kB)
    100% |████████████████████████████████| 51kB 492kB/s 
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask)
  Downloading MarkupSafe-1.0.tar.gz
Building wheels for collected packages: itsdangerous, MarkupSafe
  Running setup.py bdist_wheel for itsdangerous ... done
  Stored in directory: /Users/macbook/Library/Caches/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
  Running setup.py bdist_wheel for MarkupSafe ... done
  Stored in directory: /Users/macbook/Library/Caches/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built itsdangerous MarkupSafe
Installing collected packages: MarkupSafe, Jinja2, Werkzeug, click, itsdangerous, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.14.1 click-6.7 flask-0.12.2 itsdangerous-0.24

至此,Flask安装完毕。

打开你的pycharm,新建项目,可以看到:

点击Create

就会生成Flask的模板了:

关于Mac安装Flask的方法大家可以看一下这篇帖子,或者自己百度一下:

http://blog.csdn.net/idoshi201109/article/details/79079572/

船长对Mac也不熟悉,说实话我自己安装的过程也是云里雾里,但是可以安装成功,具体原因我们不着急解释,毕竟影响不大,即使你不安装虚拟环境直接安装Flask也没有太大的影响(个人观点)。

如果你明白Mac安装虚拟环境和Flask的原理,还请不吝赐教!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-02-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 自动化测试实战 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Windows系统安装Flask
  • Mac系统安装Flask
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档