Failed building wheel for scandir 解决方案

unbuntu 16.04 运行 pip install jupyter --upgrade 的时候出现了下面的错误

Failed building wheel for scandir
Running setup.py clean for scandir
Failed to build scandir
Installing collected packages: scandir, pathlib2, simplegeneric, pickleshare, ipython, Send2Trash, backports-abc, futures, singledispatch, tornado, pyzmq, python-dateutil, jupyter-client, terminado, ipykernel, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter-console, jupyter
Running setup.py install for scandir ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-kNCioY/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-27iuBb/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying scandir.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_scandir' extension
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _scandir.c -o build/temp.linux-x86_64-2.7/_scandir.o
_scandir.c:14:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-kNCioY/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-27iuBb/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-kNCioY/scandir/

然后在github上面找到这个

That's unrelated to IPython, the issue comes from installing scandir, you should see that with the scandir maintainers.

If you are missing Python.h during compilation that's likely because you are missing the Python header. If you are going to compile c-extensions (which you do implicitly by install in scandir) you may want to install the Python headers (apt-get install python-dev maybe ?).

大致意思就是缺少  Python.h  头文件,上面我用蓝色标出了这个错误,运行下面这个指令完美解决我的问题

apt-get install python-dev

 

posted @ 2018-04-17 13:28  tianlongtc  阅读(726)  评论(0编辑  收藏  举报