首页 > 系统相关 >CentOS6上python2.7安装memory_profiler报错

CentOS6上python2.7安装memory_profiler报错

时间:2022-11-28 00:34:01浏览次数:49  
标签:bin douban python2.7 profiler 报错 usr python27 local

由于我们需要分析python程序的内存占用问题,于是准备安装memory_profiler这个工具,

但安装过程中各种报错,以下是安装报错截图和解决过程。

1、安装

/usr/local/python27/bin/pip install -U memory_profiler

 

2、第一次测试

/usr/local/python27/bin/mprof run test.py

报错:

解决:

/usr/local/python27/bin/pip install mock -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

 

3、第二次测试

/usr/local/python27/bin/mprof run test.py

报错:

pkg_resources.DistributionNotFound: enum34

解决:

/usr/local/python27/bin/pip install enum34 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

 

4、第三次测试

/usr/local/python27/bin/mprof run test.py

报错:

pkg_resources.DistributionNotFound: pywin32

处理:

/usr/local/python27/bin/pip install pywin32 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

但处理后,失败,因为在CentOS上根本没法安装pywin32

看名字都觉得奇怪,这明明是windows上的包,怎么和memory_profiler扯上关系了。

之后尝试各种办法,用源码包装,依然不行。

 

难道跟distribute包有关吗?

于是打开那个文件:

vim /usr/local/python27/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py

找到588行:

 

我的本意是想看是否加载了pywin32,我想注释它,但没有发现pywin32的记录

于是我往上看了两眼,找到红框的部分,感觉与setuptools有关,我记得之前它也出过问题

解决方法就是重装setuptools,于是进行重装

 

5、第四次测试

/usr/local/python27/bin/mprof run test.py

 

终于成功了!!!

 

根本解决方法:重装setuptools。

但原因是啥呢?暂时不清楚。

 

标签:bin,douban,python2.7,profiler,报错,usr,python27,local
From: https://www.cnblogs.com/t-road/p/16931123.html

相关文章