python应用运行的时候报错,部分信息如下:
Traceback (most recent call last):
import _raymarching_face as _backend
ModuleNotFoundError: No module named ‘_raymarching_face’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
from ernerf.nerf_triplane.network import NeRFNetwork
raise RuntimeError(“Could not locate a supported Microsoft Visual C++ installation”)
RuntimeError: Could not locate a supported Microsoft Visual C++ installation
这是由于缺少模块_raymarching_face,这个模块是由 C++ 扩展编译生成的。我电脑上安装了Microsoft Visual Studio【使用C++的桌面开发】,但是应用就是提示我没安装Microsoft Visual C++。
打开raymarching文件夹下的setup.py,看到具体代码:
# find cl.exe
def find_cl_path():
import glob
for edition in ["Enterprise", "Professional", "BuildTools", "Community"]:
paths = sorted(glob.glob(r"C:\\Program Files (x86)\\Microsoft Visual Studio\\*\\%s\\VC\\Tools\\MSVC\\*\\bin\\Hostx64\\x64" % edition), reverse=True)
if paths:
return paths[0]
代码里显示是去C盘里寻找cl.exe的,但是我的visual studio是安装在E盘的,所以找不到,我VS安装目录如下:
将这个setup.py代码里路径地址改为如下地址:
# find cl.exe
def find_cl_path():
import glob
for edition in ["Enterprise", "Professional", "BuildTools", "Community"]:
paths = [r"E:\\Microsoft\\2022\\VC\\Tools\\MSVC\\14.40.33807\\bin\\Hostx64\\x64"]
if paths:
return paths[0]
backend.py文件里cl.exe的paths值也这样改,改成你电脑上实际的地址,同时要确保你的pytorch版本与你电脑的CUDA版本是否一致
然后在当前目录地址栏输入cmd回车,启动命令提示符界面,运行如下命令:
python setup.py build install
OK,问题解决