最近学习pytest被此问题困扰,敲脑壳,实在是不该。百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢。

报错信息如下:

网上解决方法是这样的:

1. 命名py脚本时,不要与python预留字,模块名等相同

2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件;在已经生成.pyc文件的情况下,若代码不更新,运行时依旧会走pyc,所以要删除.pyc文件),重新运行代码;或者找一个可以运行代码的环境,拷贝替换当前机器的.pyc文件即可

PS:此方法在我的问题上解决不了。

自己的解决方法:

卸载 and 重装 pytest库

1、打开cmd,输入命令:pip  uninstall pytest

2、若提示删除失败,找到D:\python\Lib\site-packages的【pytest】文件(这里的路径根据个人安装路径不同而不同),将该文件直接删除,然后再次重复第一步即可。

3、为了查看是否卸载完成,输入pip list 查看安装的所有模块,如果卸载模块操作成功,则不会再看到【pytest】模块

4、再使用 pip install pytest 命令重新安装

运行pytest后,展示了版本号,则安装成功

运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"的更多相关文章

  1. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  2. python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'

    python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...

  3. dnspython模块报错 AttributeError: 'CNAME' object has no attribute 'address'

    有时候用到这个模块的时候会报错 AttributeError: 'CNAME' object has no attribute 'address' 如下所示 [root@ansible ch01]# ...

  4. py+selenium 明明定位不到元素,但却不报错或是报错AttributeError: 'list' object has no attribute 'click'【已解决】

    问题:定位不到元素,但却不报错或者出现报错AttributeError: 'list' object has no attribute 'click' 如图  或者  解决方法:   将”driver ...

  5. 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'

    一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...

  6. 关于flask登录视图报错AttributeError: '_AppCtxGlobals' object has no attribute 'user'

    在一个小程序中写了一个登录视图函数,代码如下: @app.route('/login',methods = ['GET','POST']) @oid.loginhandler def login(): ...

  7. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  8. [已解决]pycharm报错:AttributeError: module 'pip' has no attribute 'main'

    > 更新pip后,pycharm更新模块报错,经过一番查找,现提供两种解决办法. 报错片段信息如下: AttributeError: module 'pip' has no attribute ...

  9. Centos6.5下安装jumpserver-1.4.1报错AttributeError: module 'gssapi' has no attribute 'GSSException'

    报错: >>> import paramiko Traceback (most recent call last): File "<stdin>", ...

随机推荐

  1. File Compression and Archiving in linux (linux 中文件的归档)

    1. Compressing Files at the Shell Prompt Red Hat Enterprise Linux provides the bzip2, gzip, and zip ...

  2. React中控制台警告

    1.dll_lib.js:1 Warning: bind(): You are binding a component method to the component. React does this ...

  3. adb 最常用最简单的命令-install/push/pull 使用

    以vivo测试机为例1.网上下载adb工具包,安装---网上有教程2.手机连接电脑后,进入手机设置--更多设置---开发者选项,打开开发者选项和USB调试: (不同手机开发者选项进入方式不同)3.打开 ...

  4. mybatis 源码分析(四)一二级缓存分析

    本篇博客主要讲了 mybatis 一二级缓存的构成,以及一些容易出错地方的示例分析: 一.mybatis 缓存体系 mybatis 的一二级缓存体系大致如下: 首先当一二级缓存同时开启的时候,首先命中 ...

  5. Linux Capabilities 简介

    为了执行权限检查,Linux 区分两类进程:特权进程(其有效用户标识为 0,也就是超级用户 root)和非特权进程(其有效用户标识为非零). 特权进程绕过所有内核权限检查,而非特权进程则根据进程凭证( ...

  6. vue-cli3.x创建及运行项目

    Node 版本要求 Vue CLI 需要 Node.js 8.9 或更高版本 (推荐 8.11.0+).如果你已经全局安装了旧版本的 vue-cli (1.x 或 2.x),你需要先通过 npm un ...

  7. JSONP跨域的script标签请求为什么不受同源策略的限制?

    在复习跨域的时候,复习到了JSONP跨域,大家都知道JSONP跨域是通过动态创建script标签,然后通过其src属性进行跨域请求的,前端需要一个数据处理的回调函数,而服务端需要配合执行回调函数,放入 ...

  8. PHP小补充

    code1-1 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> < ...

  9. 【系统解读】SystemUI篇(一)SystemUI启动流程

    前言 SystemUI是系统启动中第一个用户肉眼可见的应用,其功能包罗万象,比如开机后看到的锁屏界面,充电时充电界面,状态栏,导航栏,多任务栏等,都是与Android手机用户息息相关的功能.所以不止S ...

  10. HDU 6634 网络流最小割模型 启发式合并

    如果我们先手拿完所有苹果再去考虑花费的话. S -> 摄像头 -> 苹果 -> T 就相当于找到一个最小割使得S和T分开. ans = sum - flow. 然后对于这一个模型, ...