我有一个包含源代码的模块和另一个包含测试脚本的文件夹。
face_zoom
----__init__.py
----face_zoomer.py
----jumpcutter.py
test
----__init__.py
----test.py
face_zoomer.py
并分别jumpcutter.py
包含FaceZooming
和Jumpcutter
类。
测试脚本调用face_zoomer.py
文件中的一个简单函数:
from face_zoom import FaceZooming
def test_face_zoom:
[...test function...]
脚本face_zoomer.py
导入:JumpCutter
from .jumpcutter import Jumpcutter
[...other imports...]
[...class definition...]
jumpcutter.py
脚本导入 numpy :
import numpy as np
[...other imports...]
[...class definition...]
进入虚拟环境后:source venv/bin/activate
,并安装 numpy:(pip install numpy
和 pip3),然后运行 pytest pytest test/test.py::test_face_zoom -s
::
___________________________________ ERROR collecting test/test.py ____________________________________
ImportError while importing test module '/mnt/c/Users/wysko/Documents/EditorKH/JC-face/test/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/__init__.py:1: in <module>
from face_zoom import Jumpcutter, FaceZooming
face_zoom/__init__.py:1: in <module>
from .jumpcutter import Jumpcutter
face_zoom/jumpcutter.py:1: in <module>
import numpy as np
E ImportError: No module named numpy
为什么它无法访问 numpy 或任何其他非 python 标准库?