python - PyCharm IDE 中的 pytest 安装
问题描述
我是编程新手。我在以下链接中为 python 开发配置 PyCharm 社区版:https ://realpython.com/pycharm-guide/
我想在设置/工具中配置后尝试 pytest 选项并选择“默认测试运行器:Pytest”。尝试在 IDE 中运行测试时,我有:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py", line 4, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
尝试了 python 集成工具的修复选项并出现此错误:
我从 cmd 中检查了 PIP 包:使用官方 python 指南中推荐的以下命令:
1)pip --version
检查已安装的版本,并返回版本号pip 19.2.3
2 c:\users\user_name\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)
)python -m pip install -U pip setuptools wheel
检查成功,但轮子失败并出现错误,如下所示:
C:\Users\user_name>python -m pip install -U pip setuptools wheel
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1748>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1808>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1910>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A19E8>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1AC0>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/pip/
Requirement already up-to-date: pip in c:\users\user_name\appdata\local\programs\python\python38-32\lib\site-packages (19.2.3)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036E5358>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/setuptools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x03684EC8>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/setuptools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1E80>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/setuptools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1E50>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/setuptools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1D48>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/setuptools/
Requirement already up-to-date: setuptools in c:\users\user_name\appdata\local\programs\python\python38-32\lib\site-packages (41.2.0)
Collecting wheel
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1F58>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/wheel/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1B98>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/wheel/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1A30>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/wheel/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A1970>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/wheel/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x036A11A8>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions')': /simple/wheel/
ERROR: Could not find a version that satisfies the requirement wheel (from versions: none)
ERROR: No matching distribution found for wheel
我尝试修复修复/卸载并安装仍然出现这些错误我尝试从标准库引导它:
python -m ensurepip --default-pip
C:\Users\user_name>python -m ensurepip --default-pip
Looking in links: c:\Users\user_name\AppData\Local\Temp\tmpyly1wzwb
Requirement already satisfied: setuptools in c:\users\user_name\appdata\local\programs\python\python38-32\lib\site-packages (41.2.0)
Requirement already satisfied: pip in c:\users\user_name\appdata\local\programs\python\python38-32\lib\site-packages (19.2.3)
更新 1
令人惊讶的是,当我检查它时,我没有找到添加到 Windows 环境变量的 python 路径,但我确定我在安装 python 3.8 包“将 python 3.8 添加到 PATH”时检查了该选项我通过“编辑”手动将路径添加到 Windows系统环境变量”但还是有这个问题
解决方案
推荐阅读
- matplotlib - Matplotlib 分段错误 Mac OS 11(Big Sur)
- reactjs - 如何让日期在我的应用程序上正常工作?
- python - 为什么for循环在python中退出“”(空字符串)?
- javascript - 在 AWS 中使用 websocket 从服务器向连接的客户端发送消息
- javascript - 我正在使用 MCQ 创建一个网站。如何显示一个人选择的正确答案的数量?
- c++ - VS Code 在重新运行代码时产生不同的输出
- visual-studio-code - 如何在 vscode-jupyter 单元调试器中调试外部库
- python - 从 Openpagerank API 和 TypeError 获取 json 输出
- unix - 通过命令行编辑pycharm解释器
- reactjs - Next Js api静态导出在iis中返回405