pip

Python virtualenv虚拟环境

只谈情不闲聊 提交于 2021-01-30 14:49:01
在开发Python应用程序的时候,系统安装的Python3只有一个版本:3.4。所有第三方的包都会被 pip 安装到Python3的 site-packages 目录下。 如果我们要同时开发多个应用程序,那这些应用程序都会共用一个Python,就是安装在系统的Python 3。如果应用A需要jinja 2.7,而应用B需要jinja 2.6怎么办? 这种情况下,每个应用可能需要各自拥有一套“独立”的Python运行环境。virtualenv就是用来为一个应用创建一套“隔离”的Python运行环境。 首先,我们用 pip 安装virtualenv: [root@bogon ~]# pip3 install virtualenv Collecting virtualenv Downloading https://files.pythonhosted.org/packages/8b/12/8d4f45b8962b03ac9efefe5ed5053f6b29334d83e438b4fe379d21c0cb8e/virtualenv-16.7.5-py2.py3-none-any.whl (3.3MB) |████████████████████████████████| 3.3MB 615kB/s Installing collected packages: virtualenv

Pytest安装介绍--使用(html报告)

淺唱寂寞╮ 提交于 2021-01-30 06:04:36
Pytes是 一个单元测试框架,可以生成html报告。 不要点击:https://item.taobao.com/item.htm?id=613711271112 安装pytest和allure:pip install pytest : pip install allure-pytest pytest生成报告的插件:pip install pytest-html #卸载 # pip uninstall pytest #安装 # pip install -U pytest # 查看 # pytest --version 2、=========================== 2、pytest的运行“”(文件名是login.py) import pytest import allure def test_login() : print( "正在登录") if __name__ == "__main__" : pytest. main( "-s login.py" ) #命令行(用的多,要进入当前文件夹的目录运行保险):pytest -s xxx.py #如何快速打开当前项目目录? #控制台下方有一个terminal的打开即可 3、pytest配置文件ini文件:pytest.ini (必须在同一字执行目录下 ) [pytest] #添加参数 addopts = -s

pytest自动化5:pytest-html插件--生成html报告

ⅰ亾dé卋堺 提交于 2021-01-30 02:15:34
前言:pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告。兼容Python 2.7,3.6 pytest-html 1. pip 安装: pip install pytest-html 2. 执行方法: pytest (-q 指定py脚本文件) --html = report.html【目标html名称,直接写名称是在当前目录下,也可定义目录下的文件夹:./ xx文件夹/ xx.html】 随便找一个脚本执行实例看下: 好了,在demo1文件夹下可以找到report.html,打开就可以看到报告了: 3. 失败重试 失败重跑需要依赖pytest -rerunfailures插件,使用pip安装即可。 pip安装命令:pip install pytest-rerunfailures 执行命令:pytest xx.py --reruns 1 --html=report2.html --self-contained-html 【--self-contained-html加这个是为了生成的html文件自带css样式】 从报告可以看出,rerun 一次。 来源: oschina 链接: https://my.oschina.net/u/4312735/blog/3615440

pytest 失败重跑截图

爷,独闯天下 提交于 2021-01-30 02:10:13
1.环境准备 /*@param: 作者:流浪的python Date:2019/01/19 env:python 3.7(由于3.0-3.5以下部分pytest可能有部分兼容问题安装建议2.7-2.9,3.5-最新) pip install pytest专属 pytest框架包 pip install pytest-html pytest自己专属报告包 pip install pytest-rerunfailures 失败重跑包也是pytest专属 并发的也可以安下,利用多cpu运行调高用例执行速度 python -m pip install xdist 2.用例配置conftest.py编写,这个文件名必须是这个,官网指定的,pytest运行前会自己寻找这个文件,如果有会按里面配置跑没有就默认按用例设置跑,conftest.py仅对同目录,同目录下文件生效,超出按自己的conftest.py配置,每个包可以有自己的conftest.py 目录结构: https://docs.pytest.org/en/latest/pythonpath.html#test-modules-conftest-py-files-inside-packages 参考以上链接官网解释 这里我给出我的结构供参考: project/ |- __init__.py |- conftest.py |- bar/

Installing pip is not working in bitbucket CI

江枫思渺然 提交于 2021-01-29 22:14:31
问题 I am starting to make a app using bitbucket CI and i am using the following steps to deploy the application and the steps to install pip is failing. script: - apt-get update - apt-get install -y python-dev - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py ... and a few more steps Dont know why but python get-pip.py step fails with the following error. Traceback (most recent call last): File "get-pip.py", line 24226, in <module> main() File "get-pip.py", line 199, in main

How to downgrade the Python Version from 3.8 to 3.7 on windows?

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 20:57:48
问题 How can I downgrade the Python version from 3.8 to 3.7 in my virtual env? I have to install tensorflow 1.14, therefore I'm trying to downgrade the Python version. Is there a command for it using pip? 回答1: You can install multiple Python versions and set separate environment variables for each version. If you use Anaconda you can also create separate virtual environments with different python versions: conda create --name myenv --python=3.7 Or you can use something like pyenv-win to manage

Docker Ubuntu 20.04 - Cannot uninstall 'terminado' and problems with pip

馋奶兔 提交于 2021-01-29 19:02:28
问题 I'am trying to reproduce the Docker Installation of the Book "Mining the Social Web" (Russel/Klassen) on Ubuntu 20.04. I set up Docker and tried to create the Docker container from the respository directly (repo2docker https://github.com/mikhailklassen/Mining-the-Social-Web-3rd-Edition) for opening the Jupyter Notebook, but I got ERRORS. Before I installed Python3 and pip3 (couldn't install just Python and pip). Got this multiple inside the running code: WARNING: pip is being invoked by an

Mac - No module named 'scipy'

眉间皱痕 提交于 2021-01-29 18:08:45
问题 I've tried everything but can't get Scipy to work. Installed Scipy via Homebrew, seemed to work fine - but then the error when trying to import it. Uninstalled, installed via pip3, no difference. Brew doctored, brew link (forced links for the unlinked kegs for Scipy AND python), no progress. Running on macOS Mojave (10.14.6). Numpy, matplotlib and much more is working fine. What am I missing here? I have two versions of python installed, but Scipy SHOULD be installed in python3.7 (which I am

pytest失败重跑插件: pytest-rerunfailures使用与坑(全网独家精华)

泪湿孤枕 提交于 2021-01-29 15:42:09
背景 在编写接口case的时候,我们常遇到一个这样的问题: 测试环境不稳定偶发接口超时(和服务无关,纯粹是环境问题),然后执行接口case也因此偶发失败。比如同一个接口case跑五次,其中有两次失败,另外三次都是成功的,这种偶发性的环境问题就需要我们手动重跑(还不一定能够通过)。有没有一个比较好的机制,保证case能够尽最大努力通过测试呢? 这里我们介绍pytest的一个失败重跑插件: pytest-rerunfailures 介绍 pytest-rerunfailures 是一个通过重跑机制来消除不稳定失败的pytest插件。 项目地址:https://github.com/pytest-dev/pytest-rerunfailures 安装 安装&运行要求: Python 3.6~3.9, or PyPy3 pytest 5.0+ 安装插件 sudo pip(pip3) install pytest-rerunfailures 使用pytest-rerunfailures 使用方式有两种: 命令行参数 装饰器方式 命令行参数模式 示例case:test_demo.py #!/usr/bin/env python3#!coding:utf-8import pytestimport randomdef test_simple_assume(): #每次case运行的值为1或者2

Colab running Pennylane with DeviceError

大兔子大兔子 提交于 2021-01-29 14:56:13
问题 I tried to run Pennylane on Colab, so I install it first. But the "Installed devices" are null, what's going on? I have restart and rebuilt for several times. Here is my code. !pip install pennylane pennylane-qiskit import pennylane as qml qml.about() Here is the result (with nothing in "Installed devices"): Successfully built qiskit python-constraint contextvars yfinance docplex dlx Installing collected packages: semantic-version, appdirs, pennylane, sympy, fastjsonschema, retworkx, python