1、git clone https://github.com/HttpRunner/HttpRunner.git 到本地
2、查看目前正在使用的Python版本:pyenv versions,默认只有system
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, *号代表默认版本
特别建议:
优先级关系: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
11、若第七步报如下错误,使用:pip --trusted-host pypi.python.org install Flask-Script
12、启动httprunner,提示未发现HttpRunner强依赖的 'PyUnitReport'
13、install PyUnitReport
14、install PyYAML
15、install requests
16、install pyOpenSSL
17、 hrun -V
18、cd httprunner根目录下,执行export FLASK_APP=tests/api_server.py
19、接着执行flask run
遇到的问题:
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
也就是说,具体版本是要依赖于某个开发环境而存在的
解决方案:
使用 brew install python3 命令安装Python3环境,如下图所示。安装成功后再次运行:pip install HttpRunner ,错误消失。