HttpRunner环境部署-踩坑篇

1、git clone https://github.com/HttpRunner/HttpRunner.git 到本地

2、查看目前正在使用的Python版本:pyenv versions,默认只有system

image2018-1-17%2022%3A28%3A32.png?versio

3、查看可以安装的Python版本

pyenv install --list

4、官方建议Python3.6版本,so,安装需要的Python版本

pyenv install 3.6.2

5、切换Python版本,将Python 3.6.2置为默认

pyenv global 3.6.2,  *号代表默认版本

image2018-1-17%2022%3A32%3A10.png?versio

image2018-1-17%2022%3A32%3A58.png?versio

特别建议:

image2018-1-17%2022%3A36%3A34.png?versio

image2018-1-17%2022%3A36%3A59.png?versio

image2018-1-17%2022%3A37%3A11.png?versio

image2018-1-17%2022%3A37%3A21.png?versio

优先级关系:shell——local——global


6、启动服务 需要Flask-Script支持

iwm@bogon  ~  pip install Flask-Script
zsh: command not found: pip

7、提示找不到pip命令

iwm@bogon  /usr/local/Cellar  sudo easy_install pip

8、安装Flask-Script失败,error: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous.py'

iwm@bogon  /usr/local/Cellar  pip install Flask-Script
Collecting Flask-Script
Downloading Flask-Script-2.0.6.tar.gz (43kB)
100% |████████████████████████████████| 51kB 103kB/s
Collecting Flask (from Flask-Script)
Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
100% |████████████████████████████████| 92kB 110kB/s
Collecting itsdangerous>=0.21 (from Flask->Flask-Script)
Downloading itsdangerous-0.24.tar.gz (46kB)
100% |████████████████████████████████| 51kB 148kB/s
Collecting Werkzeug>=0.7 (from Flask->Flask-Script)
Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
100% |████████████████████████████████| 327kB 36kB/s
Collecting Jinja2>=2.4 (from Flask->Flask-Script)
Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
100% |████████████████████████████████| 133kB 44kB/s
Collecting click>=2.0 (from Flask->Flask-Script)
Downloading click-6.7-py2.py3-none-any.whl (71kB)
100% |████████████████████████████████| 71kB 29kB/s
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask->Flask-Script)
Downloading MarkupSafe-1.0.tar.gz
Installing collected packages: itsdangerous, Werkzeug, MarkupSafe, Jinja2, click, Flask, Flask-Script
Running setup.py install for itsdangerous ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-zQxmry-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib
copying itsdangerous.py -> build/lib
running install_lib
copying build/lib/itsdangerous.py -> /Library/Python/2.7/site-packages
error: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous.py'

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-zQxmry-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4v/19tb9yfs367804yt2wzd7vjh0000gp/T/pip-build-6iVE3v/itsdangerous/

9、chomd赋予权限

sudo chmod 777 /Library/Python/2.7/site-packages/

10、再次执行pip install Flask-Script

image2018-1-17%2021%3A55%3A46.png?versio

11、若第七步报如下错误,使用:pip --trusted-host pypi.python.org install Flask-Script

image2018-1-17%2021%3A55%3A0.png?version

12、启动httprunner,提示未发现HttpRunner强依赖的 'PyUnitReport' 

image2018-1-17%2021%3A53%3A54.png?versio

13、install PyUnitReport

image2018-1-17%2021%3A53%3A4.png?version

14、install PyYAML

image2018-1-17%2021%3A52%3A45.png?versio

15、install requests

image2018-1-17%2021%3A52%3A24.png?versio

16、install pyOpenSSL

image2018-1-17%2021%3A51%3A28.png?versio

17、 hrun -V

image2018-1-17%2021%3A51%3A55.png?versio

18、cd httprunner根目录下,执行export FLASK_APP=tests/api_server.py

image2018-1-17%2021%3A50%3A47.png?versio

19、接着执行flask run

image2018-1-17%2021%3A50%3A29.png?versio


遇到的问题:

bogon:libexec luxiaoying$ pip install HttpRunner
/usr/local/Cellar/pyenv/1.2.1/pyenv.d/exec/pip-rehash/pip: /usr/local/bin/pip: /usr/local/Cellar/python3/3.6.4_2/bin/python3.6: bad interpreter: No such file or directory

问题原因:


使用pyenv 安装了Python 3.6.4版本,并设置为默认,但提示告知Cellar下面并没有Python3。

拿Android举个例子吧,上面这种情况就像是我们只下载了某个版本的Android api,但却没有安装Android SDK

也就是说,具体版本是要依赖于某个开发环境而存在的

image2018-2-8%2012%3A1%3A5.png?version=1

解决方案:

使用 brew install python3 命令安装Python3环境,如下图所示。安装成功后再次运行:pip install HttpRunner ,错误消失。

image2018-2-8%2012%3A7%3A45.png?version=


评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页