1. 程式人生 > 實用技巧 >Mac下匯入pytest報錯 No module named pytest

Mac下匯入pytest報錯 No module named pytest

import pytest 報錯,提示No module named pytest 找不到pytest模組
解決方法:安裝pytest

pycharm --Preferences
找到project點選Porject Interpreter

右側列表是當期已經安裝的內容,這個圖是安裝後截圖所以已經包含了pytest,沒安裝的在右側列表查不到
點選+號
在彈出框裡面搜尋pytest,選中後點擊安裝
在這裡插入圖片描述

匯入pytest
在這裡插入圖片描述
安裝成功
再次使用import pytest 命令不再報錯
在這裡插入圖片描述