码迷,mamicode.com
首页 > 编程语言 > 详细

Ubuntu安装Python模块时的报错

时间:2015-05-19 07:33:13      阅读:532      评论:0      收藏:0      [点我收藏+]

标签:python   报错   安装模块   

在安装Python的psutil模块时,报“error: command ‘x86_64-linux-gnu-gcc‘ failed with exit status 1”的错误,系统提示缺少Python的头文件,那就是说系统没有安装python的开发包,安装之就行了。


$ sudo pip install psutil
[sudo] password for richard: 
Downloading/unpacking psutil
  Downloading psutil-2.2.1.tar.gz (223kB): 223kB downloaded
  Running setup.py (path:/tmp/pip_build_root/psutil/setup.py) egg_info for package psutil
    
    warning: no previously-included files matching ‘*‘ found under directory ‘docs/_build‘
Installing collected packages: psutil
  Running setup.py install for psutil
    building ‘_psutil_linux‘ extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_VERSION=221 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
    psutil/_psutil_linux.c:12:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command ‘x86_64-linux-gnu-gcc‘ failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__=‘/tmp/pip_build_root/psutil/setup.py‘;exec(compile(getattr(tokenize, ‘open‘, open)(__file__).read().replace(‘\r\n‘, ‘\n‘), __file__, ‘exec‘))" install --record /tmp/pip-t0gEEe-record/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
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
running build_ext
building ‘_psutil_linux‘ extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_VERSION=221 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
psutil/_psutil_linux.c:12:20: fatal error: Python.h: No such file or directory
 #include <Python.h>
                    ^
compilation terminated.
error: command ‘x86_64-linux-gnu-gcc‘ failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__=‘/tmp/pip_build_root/psutil/setup.py‘;exec(compile(getattr(tokenize, ‘open‘, open)(__file__).read().replace(‘\r\n‘, ‘\n‘), __file__, ‘exec‘))" install --record /tmp/pip-t0gEEe-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/psutil
Storing debug log for failure in /home/richard/.pip/pip.log


$ sudo apt-get install python-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libexpat1-dev libpython-dev libpython2.7-dev python2.7-dev
The following NEW packages will be installed:
  libexpat1-dev libpython-dev libpython2.7-dev python-dev python2.7-dev
0 upgraded, 5 newly installed, 0 to remove and 17 not upgraded.
Need to get 22.4 MB of archives.
After this operation, 35.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libexpat1-dev amd64 2.1.0-4ubuntu1 [115 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libpython2.7-dev amd64 2.7.6-8 [22.0 MB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ trusty/main libpython-dev amd64 2.7.5-5ubuntu3 [7,078 B]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ trusty/main python2.7-dev amd64 2.7.6-8 [269 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu/ trusty/main python-dev amd64 2.7.5-5ubuntu3 [1,166 B]
Fetched 22.4 MB in 42s (527 kB/s)                                              
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 372107 files and directories currently installed.)
Preparing to unpack .../libexpat1-dev_2.1.0-4ubuntu1_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-4ubuntu1) ...
Selecting previously unselected package libpython2.7-dev:amd64.
Preparing to unpack .../libpython2.7-dev_2.7.6-8_amd64.deb ...
Unpacking libpython2.7-dev:amd64 (2.7.6-8) ...
Selecting previously unselected package libpython-dev:amd64.
Preparing to unpack .../libpython-dev_2.7.5-5ubuntu3_amd64.deb ...
Unpacking libpython-dev:amd64 (2.7.5-5ubuntu3) ...
Selecting previously unselected package python2.7-dev.
Preparing to unpack .../python2.7-dev_2.7.6-8_amd64.deb ...
Unpacking python2.7-dev (2.7.6-8) ...
Selecting previously unselected package python-dev.
Preparing to unpack .../python-dev_2.7.5-5ubuntu3_amd64.deb ...
Unpacking python-dev (2.7.5-5ubuntu3) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libexpat1-dev:amd64 (2.1.0-4ubuntu1) ...
Setting up libpython2.7-dev:amd64 (2.7.6-8) ...
Setting up libpython-dev:amd64 (2.7.5-5ubuntu3) ...
Setting up python2.7-dev (2.7.6-8) ...
Setting up python-dev (2.7.5-5ubuntu3) ...
richard@richard-Dell-System:~$ sudo pip install psutil
Downloading/unpacking psutil
  Downloading psutil-2.2.1.tar.gz (223kB): 223kB downloaded
  Running setup.py (path:/tmp/pip_build_root/psutil/setup.py) egg_info for package psutil
    
    warning: no previously-included files matching ‘*‘ found under directory ‘docs/_build‘
Installing collected packages: psutil
  Running setup.py install for psutil
    building ‘_psutil_linux‘ extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_VERSION=221 -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
    x86_64-linux-gnu-gcc -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/psutil/_psutil_linux.o -o build/lib.linux-x86_64-2.7/_psutil_linux.so
    building ‘_psutil_posix‘ extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_posix.o
    x86_64-linux-gnu-gcc -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/psutil/_psutil_posix.o -o build/lib.linux-x86_64-2.7/_psutil_posix.so
    
    warning: no previously-included files matching ‘*‘ found under directory ‘docs/_build‘
Successfully installed psutil
Cleaning up...
$ sudo pip install psutil



本文出自 “天道酬勤” 博客,请务必保留此出处http://lavenliu.blog.51cto.com/5060944/1652510

Ubuntu安装Python模块时的报错

标签:python   报错   安装模块   

原文地址:http://lavenliu.blog.51cto.com/5060944/1652510

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!