python3.6安装memory_profiler
Posted 心有事焉 勿忘勿助
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3.6安装memory_profiler相关的知识,希望对你有一定的参考价值。
1. 在centos中安装memory_profiler
pip3 install memory_profiler
报了个错:
running build_ext
building ‘psutil._psutil_linux‘ extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/psutil
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=570 -DPSUTIL_LINUX=1 -I/usr/include/python3.6m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command ‘gcc‘ failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__=‘/tmp/pip-build-ctdkmofk/psutil/setup.py‘;f=getattr(tokenize, ‘open‘, open)(__file__);code=f.read().replace(‘
‘, ‘
‘);f.close();exec(compile(code, __file__, ‘exec‘))" install --record /tmp/pip-nuiv1vvh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ctdkmofk/psutil/
解决方式:
sudo yum install python3-devel
2.重新安装memory_profiler
pip3 install memory_profiler
输出如下:
Collecting memory_profiler
Downloading http://mirrors.tencentyun.com/pypi/packages/f4/03/175d380294b2333b9b79c2f2aa235eb90ee95e3ddef644497a9455404312/memory_profiler-0.57.0.tar.gz
Collecting psutil (from memory_profiler)
Downloading http://mirrors.tencentyun.com/pypi/packages/c4/b8/3512f0e93e0db23a71d82485ba256071ebef99b227351f0f5540f744af41/psutil-5.7.0.tar.gz (449kB)
100% |████████████████████████████████| 450kB 1.5MB/s
Installing collected packages: psutil, memory-profiler
Running setup.py install for psutil ... done
Running setup.py install for memory-profiler ... done
Successfully installed memory-profiler-0.57.0 psutil-5.7.0
ok. 成功!记一下备忘。
以上是关于python3.6安装memory_profiler的主要内容,如果未能解决你的问题,请参考以下文章
使用 memory_profiler 在 Flask 应用程序中分析行
如何使用 Python 多处理和 memory_profiler 分析多个子进程?
Python3 memory_profiler,同时使用lambda表达式连接PyQt5中的插槽