Python 未安装 BLAS/LAPACK:如何安装?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25065113/
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-18 19:40:52  来源:igfitidea点击:

BLAS/LAPACK not installed: How to install it?

pythonc++bashubuntu

提问by pg2455

I am trying to run pip install tsnefor python2.7 and I keep on getting the same error. I followed the instructions on http://bickson.blogspot.com/2011/02/installing-blaslapackitpp-on-amaon-ec2.htmland installed LAPACK/BLAS which I thought should have solved the problem. Nothing helped. What am I doing wrong? I am less familiar with bash.

我正在尝试pip install tsne为 python2.7运行,但我不断收到相同的错误。我按照http://bickson.blogspot.com/2011/02/installing-blaslapackitpp-on-amaon-ec2.html上的说明操作并安装了 LAPACK/BLAS,我认为应该已经解决了问题。没有任何帮助。我究竟做错了什么?我对 bash 不太熟悉。

running build_ext

cythoning tsne/bh_sne.pyx to tsne/bh_sne.cpp

building 'bh_sne' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/tsne

creating build/temp.linux-x86_64-2.7/tsne/bh_sne_src

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/ubuntu/env/work/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -Itsne/bh_sne_src/ -I/usr/include/python2.7 -c tsne/bh_sne_src/quadtree.cpp -o build/temp.linux-x86_64-2.7/tsne/bh_sne_src/quadtree.o -msse2 -O3 -fPIC -w

cc1plus: warning: command line option ‘-Wstrict-prototypes' is valid for C/ObjC but not for C++ [enabled by default]

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/ubuntu/env/work/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -Itsne/bh_sne_src/ -I/usr/include/python2.7 -c tsne/bh_sne_src/tsne.cpp -o build/temp.linux-x86_64-2.7/tsne/bh_sne_src/tsne.o -msse2 -O3 -fPIC -w

cc1plus: warning: command line option ‘-Wstrict-prototypes' is valid for C/ObjC but not for C++ [enabled by default]

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/ubuntu/env/work/local/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -Itsne/bh_sne_src/ -I/usr/include/python2.7 -c tsne/bh_sne.cpp -o build/temp.linux-x86_64-2.7/tsne/bh_sne.o -msse2 -O3 -fPIC -w

cc1plus: warning: command line option ‘-Wstrict-prototypes' is valid for C/ObjC but not for C++ [enabled by default]

c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/tsne/bh_sne_src/quadtree.o build/temp.linux-x86_64-2.7/tsne/bh_sne_src/tsne.o build/temp.linux-x86_64-2.7/tsne/bh_sne.o -L/usr/local/lib -o build/lib.linux-x86_64-2.7/bh_sne.so -lcblas

/usr/bin/ld: cannot find -lcblas

collect2: error: ld returned 1 exit status

error: command 'c++' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/ubuntu/env/work/bin/python -c "import setuptools, tokenize;__file__='/home/ubuntu/env/work/build/tsne/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3X17dU-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/env/work/include/site/python2.7 failed with error code 1 in /home/ubuntu/env/work/build/tsne
Traceback (most recent call last):
  File "/home/ubuntu/env/work/bin/pip", line 11, in 
    sys.exit(main())
  File "/home/ubuntu/env/work/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/home/ubuntu/env/work/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)

采纳答案by Michel Müller

Ubuntu doesn't have a binary distribution of either cblas or openblas, which are required for tsne according to their github. However, ATLAS, which is available on Ubuntu, comes with precompiled cblas.

Ubuntu 没有 cblas 或 openblas 的二进制发行版,根据他们的github,这是 tsne 所必需的。但是,在 Ubuntu 上可用的 ATLAS 带有预编译的 cblas。

In Ubuntu, debian, that should work with:

在 Ubuntu 和 debian 中,它应该适用于:

apt-get install libatlas-base-dev 

https://launchpad.net/ubuntu/+source/atlas

https://launchpad.net/ubuntu/+source/atlas

If you need to have different compiler options, you'll have to build openblas yourself.

如果您需要不同的编译器选项,则必须自己构建 openblas。

And check that you get libcblas.a in /usr/lib

并检查您是否在 /usr/lib 中获得了 libcblas.a

Edited: Corrected package name.

编辑:更正了包名称。

回答by tmyklebu

Download a copy of OpenBLAS and compile it yourself. Install it into /usr/localusing make install. There are OpenBLAS and ATLAS packages and whatever else in the official repositories, but their performance is suspect.

下载 OpenBLAS 的副本并自行编译。将其安装到/usr/localusing 中make install。官方存储库中有 OpenBLAS 和 ATLAS 包以及其他任何东西,但它们的性能值得怀疑。

回答by Harsh Wardhan

Use this:

用这个:

sudo apt-get install libblas-dev liblapack-dev