使用PyCharm安装pytest及requests的问题
作者:cathyyyyy呀 时间:2023-01-17 13:10:46
电脑环境:windows7 64位 python3.7
问题:在PyCharm中,使用setting下的project Interpreter安装pytest以及requests失败
解决方法:(亲测有效)
1、打开Gitbash,定位到python的安装目录:我的安装目录是 D:\pythonAnZhuang\Python37\Scripts
2、输入:pip install requests,等待安装完成
3、输入:pip install pytest,等待安装完成
4、检测是否安装成功的方法:
第一种:pip list 可看到清单中有pytest以及requests
第二种:打开python3.7的IDE,输入 import pytest不报错,输入import requests不报错
5、打开PyCharm
可以在代码中使用pytest以及requests。如果不能导入,检查pytest和requests是否在虚拟环境中。
(我的其中一个包requests在虚拟环境中,转移到虚拟环境中创建脚本导入requests成功。)
6、注意事项:在requests安装后出现的问题:虽然程序中可以导入模块,但是程序执行时仍报错,提示找不到模块。
解决方法:此时打开gitbash,定位到python安装目录,我的是 D:\pythonAnZhuang\Python37,先卸载request(执行pip unstall requests),然后再安装(执行pip install requests)。
安装后,回到PyCharm,打开setting下的project Interpreter安装requests成功。
来源:https://blog.csdn.net/qq_35055695/article/details/107702761
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
JavaScript求一组数的最小公倍数和最大公约数常用算法详解【面向对象,回归迭代和循环】
python开发的自动化运维工具ansible详解
![](https://img.aspxhome.com/file/2023/8/64298_0s.jpg)
vue实现鼠标滑动展示tab栏切换
![](https://img.aspxhome.com/file/2023/4/139744_0s.gif)
getElementsByTagName vs selectNodes效率 及兼容的selectNodes实现
Bootstrap Paginator分页插件使用方法详解
![](https://img.aspxhome.com/file/2023/4/56294_0s.png)
php时间戳格式化显示友好的时间函数分享
Python socket实现的简单通信功能示例
![](https://img.aspxhome.com/file/2023/6/79516_0s.gif)
Python安装第三方库攻略(pip和Anaconda)
![](https://img.aspxhome.com/file/2023/1/65021_0s.png)
laravel学习教程之存取器
如何实现删除numpy.array中的行或列
深入理解Django的自定义过滤器
![](https://img.aspxhome.com/file/2023/1/71421_0s.jpg)
微信小程序开发常见问题及解决方案
![](https://img.aspxhome.com/file/2023/1/136441_0s.png)
Vue首屏时间指标采集最佳方式详解
![](https://img.aspxhome.com/file/2023/4/123054_0s.jpg)
Go语言 如何实现RSA加密解密
![](https://img.aspxhome.com/file/2023/4/125084_0s.jpg)
Sql Server 2005 默认端口修改方法
mat矩阵和npy矩阵实现互相转换(python和matlab)
![](https://img.aspxhome.com/file/2023/7/90877_0s.png)
用Python实现定时备份Mongodb数据并上传到FTP服务器
![](https://img.aspxhome.com/file/2023/2/80472_0s.png)