Python:无法导入模块

时间:2020-02-12 02:26:36

标签: python pytest

我正在使用pytest运行测试。 Conftest.py正在导入一个称为airflow的模块,该模块位于站点包中。

airflow.hooks.postgres_hook导入PostgresHook

导入失败,出现以下错误:

enter image description here

airflow也是项目中与测试文件夹相同级别的文件夹。

enter image description here

所以当测试运行时 sys.path看起来像:

['/ data / airflow / dataeng_workflows_install','/ data / anaconda / envs / py36 / bin','/data/anaconda/envs/py36/lib/python36.zip','/ data / anaconda / envs / py36 / lib / python3.6','/ data / anaconda / envs / py36 / lib / python3.6 / lib-dynload','/ data / anaconda / envs / py36 / lib / python3.6 /网站软件包”]

它在第一条路径中找到气流,因此它失败了,而不是从sys.path中最后一个的站点程序包中获取了气流

是否可以进行导入?

0 个答案:

没有答案
相关问题