代码中使用 from multiprocessing import Pool提示Pool未定义
尝试从pycharm安装,报错,如下:
尝试用pip安装,出错如下:
$ pip3 install multiprocessing
Collecting multiprocessing
Using cached multiprocessing-2.6.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/w0/7cdmk6ss44sfc2p4kv4t_zxc0000gn/T/pip-build-p_mrlozs/multiprocessing/setup.py", line 94
print 'Macros:'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(int 'Macros:')?
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/w0/7cdmk6ss44sfc2p4kv4t_zxc0000gn/T/pip-build-p_mrlozs/multiprocessing/
multiprocessing-2.6.2.1.tar.gz 目测是支持python 2.x下运行的包, 而你的python 是3.x 要改为相应的版本才行
如下例中
语法区别:
从 Python 2.6起, multiprocessing 是python的内置模块, 不需要用pip安装.