python - Ubuntu16.04下virtualenv中psutil的安装

标签 python python-3.x virtualenv psutil

我的安装可能出了什么问题?

我正在尝试安装psutilvirtualenv在我的 Ubuntu16.04 上。

应该非常简单,如 pip3 install psutil .

但是我有错误

Collecting psutil
  Using cached https://files.pythonhosted.org/packages/e3/58/0eae6e4466e5abf779d7e2b71fac7fba5f59e00ea36ddb3ed690419ccb0f/psutil-5.4.8.tar.gz
Building wheels for collected packages: psutil
  Running setup.py bdist_wheel for psutil ... error
  Complete output from command /home/coie/virtualenvironment/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lrbka3xy/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-29fvmytd --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/psutil
  copying psutil/__init__.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_psaix.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_exceptions.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_psosx.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_common.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_compat.py -> build/lib.linux-x86_64-3.5/psutil
  copying psutil/_psposix.py -> build/lib.linux-x86_64-3.5/psutil
  creating build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.5/psutil/tests
  copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.5/psutil/tests
  running build_ext
  building 'psutil._psutil_linux' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/psutil
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=548 -DPSUTIL_LINUX=1 -I/usr/include/python3.5m -I/home/coie/virtualenvironment/venv/include/python3.5m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.5/psutil/_psutil_common.o
  psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for psutil
  Running setup.py clean for psutil
Failed to build psutil
Installing collected packages: psutil
  Running setup.py install for psutil ... error
    Complete output from command /home/coie/virtualenvironment/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lrbka3xy/psutil/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-ow0brxi_/install-record.txt --single-version-externally-managed --compile --install-headers /home/coie/virtualenvironment/venv/include/site/python3.5/psutil:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/psutil
    copying psutil/__init__.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_pslinux.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_pssunos.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_pswindows.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_psaix.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_psbsd.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_exceptions.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_psosx.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_common.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_compat.py -> build/lib.linux-x86_64-3.5/psutil
    copying psutil/_psposix.py -> build/lib.linux-x86_64-3.5/psutil
    creating build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/__init__.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/__main__.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.5/psutil/tests
    copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.5/psutil/tests
    running build_ext
    building 'psutil._psutil_linux' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/psutil
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=548 -DPSUTIL_LINUX=1 -I/usr/include/python3.5m -I/home/coie/virtualenvironment/venv/include/python3.5m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.5/psutil/_psutil_common.o
    psutil/_psutil_common.c:9: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 "/home/coie/virtualenvironment/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-lrbka3xy/psutil/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-ow0brxi_/install-record.txt --single-version-externally-managed --compile --install-headers /home/coie/virtualenvironment/venv/include/site/python3.5/psutil" failed with error code 1 in /tmp/pip-install-lrbka3xy/psutil/

最佳答案

sudo apt-get install python3-dev 应该可以解决你的问题。

关于python - Ubuntu16.04下virtualenv中psutil的安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53516360/

相关文章:

python - 如何在 virtualenv 中运行 python 脚本

python - Groupby 2 列并查找多个其他列的 .min (python pandas)

python - 在 Selenium 测试中摆脱 JQuery DatePicker

Powershell 中的 Python 2 和 3

python - 如何从FastApi中的请求读取非json数据

python - Windows 上的 virtualenv/virtualenvwrapper-win 中的环境变量

python - 什么是 %pylab?

python - 如何在 Python 中将列表元素从第二个元素链接到最后一个元素

python-3.x - Python 3.7 非阻塞请求?

python - 凌乱的 Python 安装? (OS X)