鍍金池/ 問(wèn)答/Python/ 使用pycharm安裝multiprocessing出錯(cuò)

使用pycharm安裝multiprocessing出錯(cuò)

代碼中使用 from multiprocessing import Pool提示Pool未定義
嘗試從pycharm安裝,報(bào)錯(cuò),如下:

圖片描述

嘗試用pip安裝,出錯(cuò)如下:
$ 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 目測(cè)是支持python 2.x下運(yùn)行的包, 而你的python 是3.x 要改為相應(yīng)的版本才行

如下例中

$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56) 
>>> print 'test'
test

語(yǔ)法區(qū)別:

$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
>>> print 'test'
  File "<stdin>", line 1
    print 'test'
               ^
SyntaxError: Missing parentheses in call to 'print'

從 Python 2.6起, multiprocessing 是python的內(nèi)置模塊, 不需要用pip安裝.

2018年6月22日 19:15
編輯回答
別瞎鬧

報(bào)錯(cuò)信息已經(jīng)提示你了可能版本不對(duì):

clipboard.png

在pycharm里搜索這個(gè)包時(shí)有下這個(gè)描述的:
Backport of the multiprocessing package to Python 2.4 and 2.5

也就是說(shuō)這個(gè)包是為2.4和2.5版本的python用的,而且你的3.6的版本其實(shí)已經(jīng)內(nèi)置了這個(gè)包。

2018年1月17日 22:33