Ubuntu安裝Python模組時的報錯

來源:互聯網
上載者:User

標籤: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 installrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-2.7creating build/lib.linux-x86_64-2.7/psutilcopying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutilcopying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutilrunning build_extbuilding ‘_psutil_linux‘ extensioncreating build/temp.linux-x86_64-2.7creating build/temp.linux-x86_64-2.7/psutilx86_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.opsutil/_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/psutilStoring debug log for failure in /home/richard/.pip/pip.log$ sudo apt-get install python-dev Reading package lists... DoneBuilding dependency tree       Reading state information... DoneThe following extra packages will be installed:  libexpat1-dev libpython-dev libpython2.7-dev python2.7-devThe following NEW packages will be installed:  libexpat1-dev libpython-dev libpython2.7-dev python-dev python2.7-dev0 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] YGet: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) ...[email protected]:~$ sudo pip install psutilDownloading/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 psutilCleaning up...$ sudo pip install psutil



本文出自 “天道酬勤” 部落格,請務必保留此出處http://lavenliu.blog.51cto.com/5060944/1652510

Ubuntu安裝Python模組時的報錯

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.