Python 安装mpi4py时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28440834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 03:17:43  来源:igfitidea点击:

Error when installing mpi4py

pythonmacosinstallationmpi

提问by nargles324

I'm trying to install mpi4py using pip install mpi4py, but I'm getting the following error:

我正在尝试使用 pip install mpi4py 安装 mpi4py,但出现以下错误:

error: Cannot find 'mpi.h' header. Check your configuration!!!

Earlier in the same error report I have,

在我之前的同一个错误报告中,

clang: error: linker command failed with exit code 1 (use -v to see    invocation)

What might the problem be?

可能是什么问题?

Thanks!

谢谢!

回答by Rob Latham

If mpi4py cannot find mpi.h, then likely the problem is how you are pointing mpi4py to your existing mpi library.

如果mpi4py 找不到mpi.h,那么问题很可能是您如何将mpi4py 指向现有的mpi 库。

$ python setup.py build --mpicc=/where/you/have/mpicc

Now, there there are a few special cases related to OS X. You should consult http://mpi4py.scipy.org/docs/usrman/install.htmlto see if any apply to you.

现在,有一些与 OS X 相关的特殊情况。您应该查阅http://mpi4py.scipy.org/docs/usrman/install.html以查看是否有任何适用于您的情况。

回答by American curl

I met with the similar problem and fixed this by firstly

我遇到了类似的问题并首先解决了这个问题

brew install mpich

And then

进而

pip install mpi4py

回答by mcshell

As the error says, there are libraries missing. I solved it by installing libopenmpi-dev package

正如错误所说,缺少库。我通过安装 libopenmpi-dev 包解决了它

sudo apt install libopenmpi-dev

and then installed the mpi4py using pip

然后使用pip安装了mpi4py

sudo pip install mpi4py

回答by demonchang

you can do this:

你可以这样做:

brew install mpich

then

然后

sudo find / -name mpicc

finally

最后

env MPICC=/yourpath/mpicc pip3 install mpi4py

回答by thepith

If somebody stumbles by and has the same problem I had:

如果有人偶然发现并遇到了与我相同的问题:

I wanted to install mpi4py using pip as root:

我想使用 pip 作为 root 安装 mpi4py:

sudo pip install mpi4py

I got the error message that mpi.hwas missing during the installation. The path was set correctly, but only for my user, not for root. So if you run into trouble with missing libraries/headers during any installation, make sure the correct environment is also set up for root.

我收到mpi.h了安装过程中丢失的错误消息。路径设置正确,但仅适用于我的用户,不适用于 root。因此,如果您在任何安装过程中遇到缺少库/头文件的问题,请确保也为 root 设置了正确的环境。

As I use mpi-selectorto select which mpi implementation you use, I just had to run mpi-selectoras root to set up everything correctly, and the installation succeeded.

当我mpi-selector用来选择您使用的 mpi 实现时,我只需要以mpi-selectorroot 身份运行即可正确设置所有内容,并且安装成功。

回答by frikg

first post here and new to python , sorry if im off topic.

第一次在这里发帖并且是 python 的新手,抱歉,如果我跑题了。

i finally installed mpi4py

我终于安装了mpi4py

1) by downloading the right version from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#mpi4py

1) 从这里下载正确的版本 https://www.lfd.uci.edu/~gohlke/pythonlibs/#mpi4py

2) open cmd ,change directory to where the downloaded file is

2)打开cmd,将目录切换到下载文件所在的位置

3) pip install some-package.whl ( How do I install a Python package with a .whl file?)

3) pip install some-package.whl(如何安装带有 .whl 文件的 Python 包?

回答by andrei sokurov

None of the above solutions worked for me. I just use the conda install:

以上解决方案都不适合我。我只使用 conda 安装:

brew install mpich
conda install mpi4py