【发布时间】:2022-06-30 07:25:29
【问题描述】:
我正在使用安装了 PyTorch 的 conda。我有以下文件test.py:
import torch
def test_test():
print(torch.Tensor([1,2]))
test_test()
运行python test.py 工作正常:
> python test.py
tensor([1., 2.])
但是使用pytest 运行它会给我一个错误:
> pytest test.py
(...)
ModuleNotFoundError: No module named 'torch'`.
这里有什么问题?
【问题讨论】: