python报错E ModuleNotFoundError: No module named 'x'

导入框架包pytest运行后报错

conftest.py

import logging
import sys
from os.path import dirname, realpath, join
import pytest

logger = logging.getLogger(__name__)
sys.path.append(join(dirname(dirname(realpath(__file__))), 'src'))
from matf.settings import *

img

img

可以不报错正常运行

用的是python3.7的环境吗

你的包是通过pycharm安装的吗,那你在pycharm下运行就没有问题
不要跑到cmd下执行,因为包不在系统默认的位置
要么你把包写入环境变量,要么复制到工程目录下