'OSError: [Errno 22] Invalid argument: 'D:\\pyCHram\\<input>'

I use ‘ProcessPoolExecutor’ to handle some data on PyCharm,but i get this error:"OSError: [Errno 22] Invalid argument: 'D:\pyCHram\'"。 But I don't know why, I dont write any code about the file path. 'D:\pyCHram\' is the folder that i save python file. Thank you very much for answering my questions. The part of the code is below:

if __name__ == '__main__':
    data_result = []
    startTime = datetime.datetime.now()
    pool = ProcessPoolExecutor(3)
    for i in range(3):
        future = pool.submit(search,poolArgsList[i],data_1)
      ###poolArgsList[i] and data_1   both areparameter.
        data_result.append(future)
    endTime = datetime.datetime.now()
    print((endTime-startTime).seconds)


Solution 1:[1]

That does look like an error I bit my teeth out once. In my case, it did not happen, once executed from terminal instead of PyCharm's console. A workaround was to set __file__ = 'workaround.py' (an empty file in the directory of your project).

Got the workaround from the comments of the open issue at jetbrains: https://youtrack.jetbrains.com/issue/PY-36151/Can-t-create-Pool-in-multiprocessing-in-Python-Console

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1