Python CPU Count可以在一台Windows服务器上运行,而不能在另一台Windows服务器上运行? [英] Python CPU Count works on one windows server but not on another?

查看:67
本文介绍了Python CPU Count可以在一台Windows服务器上运行,而不能在另一台Windows服务器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些可在Windows XP和Windows Server 2008 64位版本上使用的代码.但是,我刚刚启动了一个Amazon Windows 64位实例,并且代码失败.

I have written come code that has worked on both Windows XP and Windows Server 2008 64-Bit. However I have just launched an Amazon Windows 64-bit instance and the code fails.

很简单,看起来像这样

import multiprocessing

processors = multiprocessing.cpu_count()
print processors

我收到一个NotImplementedError,我不理解,文档对解释没有帮助.

I receive a NotImplementedError which I do not understand and the docs are not that helpful in explaining.

我只是不明白为什么它可以在一台服务器上运行,而不能在安装相同Python 2.7的另一台服务器上运行

I just do not understand why it would work on one server and not on another with identical installations of Python 2.7

还有其他人遇到这个问题/错误吗?

Anyone else run into this problem/error?

推荐答案

可能只是多处理模块,请尝试使用

It might be just the multiprocessing module, try using the psutil module it might work. SO in your case just do:

import psutil
processors = psutil.cpu_count()
print processors
>>> 4

我在Amazon Windows 64位上尝试了此方法,并且效果很好.

I tried this on the Amazon Windows 64-bit and it works quite well.

这篇关于Python CPU Count可以在一台Windows服务器上运行,而不能在另一台Windows服务器上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆