池(num_cores)由于PermissionError而崩溃:[WinError 5]访问被拒绝

时间:2020-03-11 10:44:48

标签: python python-3.x multiprocessing python-multiprocessing

因此,在重新安装Python和Pycharm之前,我有以下代码似乎可以正常工作:

from multiprocessing import cpu_count, Pool
num_cores = cpu_count()
pool = Pool(num_cores)

这会出现以下错误:

OSError: [Errno 22] Invalid argument: 'D:\\Dropbox\\3_Master_Program\\Master_Thesis\\1_Code\\<input>'
Traceback (most recent call last):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
        new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError    : _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)[WinError 5] Access is denied
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)PermissionError    
_winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: : [WinError 5] Access is denied[WinError 5] Access is denied
PermissionError: [WinError 5] Access is denied
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError:     new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
[WinError 5] Access is denied
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\spawn.py", line 99, in spawn_main
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "C:\Users\patri\Miniconda3\envs\master_thesis\lib\multiprocessing\reduction.py", line 87, in steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied

我不知道为什么会这样,我将不胜感激。我必须提到,我是在自己创建的conda环境中执行此操作的。

编辑:显然,这与我的conda环境有关。在根环境下,此错误不会出现

0 个答案:

没有答案