OSError: [Errno 22] 无效参数: 'D:\\pyCHram\\'
我使用 'ProcessPoolExecutor' 来处理 PyCharm 上的一些数据,但我收到此错误:“OSError: [Errno 22] Invalid argument: 'D:\pyCHram\'”。 但不知道为什么,我没有写任何关于文件路径的代码。 'D:\pyCHram\' 是我保存 python 文件的文件夹。非常感谢您回答我的问题。 部分代码如下:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来确实是一个错误,我曾经咬过牙。
就我而言,一旦从终端而不是 PyCharm 的控制台执行,这种情况就不会发生。
解决方法是
设置 __file__ = 'workaround.py'
(项目目录中的空文件)。从 jetbrains 上未解决问题的评论中找到了解决方法: https://youtrack.jetbrains.com/issue/PY-36151/Can-t-create-Pool-in-multiprocessing-in-Python-Console
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