在Windows 7上尝试在Anaconda中安装pymc时出现奇怪错误?

1 投票
2 回答
1628 浏览
提问于 2025-04-18 15:58

我想用马尔可夫链蒙特卡洛方法来做一些数据科学的算法,进行贝叶斯分析,现在我在安装PyMC的时候遇到了一个让我很烦恼的错误...

File "C:\Anaconda\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line 333, in get_libraries
raise NotImplementedError("Only MS compiler supported with gfortran on win64")
NotImplementedError: Only MS compiler supported with gfortran on win64

为什么会出现这个问题?我该怎么解决呢?我不想去修改Python或者numpy,因为这样可能会在以后导致其他问题。

2 个回答

1

接着Leon的回答,我的情况是,默认的Fortran编译器是mingw32,而gnu.py却在期待msvc。对于PyMC来说,mingw32是可以正常工作的,所以如果你想要放宽这个条件,而不是完全去掉它,可以把

        if c_compiler and c_compiler.compiler_type == "msvc":
            return []
        else:
            raise NotImplementedError("Only MS compiler supported with gfortran on win64")

gnu.py中替换为

        if c_compiler and c_compiler.compiler_type in ["msvc", "mingw32"]:
            return []
        else:
            raise NotImplementedError("Only MS compiler supported with gfortran on win64")
4

结果发现,如果我直接去到那一行代码...

"C:\Anaconda\lib\site-packages\numpy\distutils\fcompiler\gnu.py"

然后把那条语句注释掉,让它变成这样 -

else:
    pass #raise NotImplementedError("Only MS compiler supported with gfortran on win64")

PyMC 就能正常编译了。

撰写回答