我是一个蟒蛇新手。 我正在尝试手册中的这段代码片段,但是我收到了这个错误。 无法弄清楚为什么。 任何帮助将不胜感激。 THX
#/usr/bin/python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
def f(x):
return x*x
p = Pool(1)
p.map(f, [1, 2, 3])
[root@localhost mpls-perf]# python thr_1.py
Traceback (most recent call last):
File "thr_1.py", line 4, in <module>
from multiprocessing import Pool
File "/usr/lib64/python2.7/multiprocessing/__init__.py", line 65, in <module>
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib64/python2.7/multiprocessing/util.py", line 340, in <module>
class ForkAwareLocal(threading.local):
AttributeError: 'module' object has no attribute 'local'
Exception AttributeError: '_shutdown' in <module 'threading'
from '/root/nfs/zebos/tests/mpls- perf/threading.pyc'> ignored
OS等 [root @ localhost mpls-perf] #uname -a Linux localhost.localdomain 3.4.4464bit-smp-xp1.1-allpatch#1 SMP Wed Oct 15 17:34:02 EDT 2014 x86_64 x86_64 x86_64 GNU / Linux
[root @ localhost mpls-perf] #python -V Python 2.7.5 [root @ localhost mpls-perf]
答案 0 :(得分:5)
您似乎有一个名为threading.py
由multiprocessing
而不是内置threading
将您的文件重命名为其他内容并删除.pyc