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

16 投票
3 回答
48780 浏览
提问于 2025-04-18 15:31

我正在尝试在python2.7上运行 pip install tsne,但总是遇到同样的错误。我按照这个链接上的说明 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)

3 个回答

2

下载一个OpenBLAS的副本,然后自己编译。使用 make install 命令把它安装到 /usr/local 这个文件夹里。官方的仓库里有OpenBLAS和ATLAS的安装包,还有其他一些,但它们的性能可能不太可靠。

8

使用这个:

sudo apt-get install libblas-dev liblapack-dev
28

在Ubuntu系统上,没有直接可以用的cblas或openblas这两个软件包,而这两个软件包是使用tsne时需要的,具体可以查看他们的github页面。不过,Ubuntu上有一个叫ATLAS的工具,它里面已经包含了预编译好的cblas。

在Ubuntu和debian系统上,可以用以下命令来安装:

apt-get install libatlas-base-dev 

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

如果你需要使用不同的编译选项,那就需要自己编译openblas了。

另外,要确保你在/usr/lib目录下能找到libcblas.a这个文件。

编辑:修正了软件包的名称。

撰写回答