我已经在 Ubuntu 上安装了 pip3。但是在使用它安装 numpy(使用命令“pip3 install numpy”)时,我收到以下错误 -
error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Ibuild/src.linux-x86_64-3.5/numpy/core/src/common -Inumpy/core/include -Ibuild/src.linux-x86_64-3.5/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python3.5m -Ibuild/src.linux-x86_64-3.5/numpy/core/src/common -Ibuild/src.linux-x86_64-3.5/numpy/core/src/npymath -Ibuild/src.linux-x86_64-3.5/numpy/core/src/common -Ibuild/src.linux-x86_64-3.5/numpy/core/src/npymath -c build/src.linux-x86_64-3.5/numpy/core/src/npysort/radixsort.c -o build/temp.linux-x86_64-3.5/build/src.linux-x86_64-3.5/numpy/core/src/npysort/radixsort.o -MMD -MF build/temp.linux-x86_64-3.5/build/src.linux-x86_64-3.5/numpy/core/src/npysort/radixsort.o.d" failed with exit status 1
我找不到类似错误的答案。有人能帮忙解决这个错误吗?
答案1
我找到了一个和你的问题很相似。 简而言之:
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
我稍微改变了原来的答案以适应python3(python-dev
改为python3-dev
答案2
我在尝试在 Raspberry Pi 上安装 TensorFlow 时偶然发现了这个问题。由于我的错误代码看起来很相似,但还包含以下文本:
numpy/core/src/npysort/radixsort.c.src: In function ‘aradixsort_ulonglong’: numpy/core/src/npysort/radixsort.c.src:202:5: error: ‘for’ loop initial declarations are only allowed in C99 mode for (npy_intp i = 1; i < num; i++) { ^ error: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/pi/berryconda3/envs/tfcpu/include -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC -O2 -pipe -I/home/pi/berryconda3/envs/tfcpu/include -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC -O2 -pipe -fPIC -Ibuild/src.linux-armv7l-3.6/numpy/core/src/common -Inumpy/core/include -Ibuild/src.linux-armv7l-3.6/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/home/pi/berryconda3/envs/tfcpu/include/python3.6m -Ibuild/src.linux-armv7l-3.6/numpy/core/src/common -Ibuild/src.linux-armv7l-3.6/numpy/core/src/npymath -Ibuild/src.linux-armv7l-3.6/numpy/core/src/common -Ibuild/src.linux-armv7l-3.6/numpy/core/src/npymath -c build/src.linux-armv7l-3.6/numpy/core/src/npysort/radixsort.c -o build/temp.linux-armv7l-3.6/build/src.linux-armv7l-3.6/numpy/core/src/npysort/radixsort.o -MMD -MF build/temp.linux-armv7l-3.6/build/src.linux-armv7l-3.6/numpy/core/src/npysort/radixsort.o.d" failed with exit status 1
通过谷歌,我找到了以下 Github 讨论,在那里我找到了回答。这是来自 github 的答案 - 归功于乌龙茶:
CFLAGS=-std=c99 pip install numpy