这个错误的原因是什么:“PermissionError: [WinError 5] Access is denied" [英] What is the reason of this errror: "PermissionError: [WinError 5] Access is denied"

查看:78
本文介绍了这个错误的原因是什么:“PermissionError: [WinError 5] Access is denied"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 Pycharm2018.3.3 上运行此示例代码,但没有成功.但是相同的代码可以在 IDLE 上运行而不会出现任何错误.

I try to run this example code on Pycharm2018.3.3, it didn't work out. But the same code can run on the IDLE without any error.

我的环境是Python3.7 + windows10.

My environment is Python3.7 + windows10.

from multiprocessing import Process, Queue

def f(q):
    q.put([42, None, 'hello'])

if __name__ == '__main__':
    q = Queue()
    p = Process(target=f, args=(q,))
    p.start()
    print(q.get())    # prints "[42, None, 'hello']"
    p.join()

Process Process-1:
Traceback (most recent call last):
  File "C:\Users\WYM\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\process.py", line 297, in _bootstrap
    self.run()
  File "C:\Users\WYM\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "E:\Spider2\ControlNode\test.py", line 4, in f
    q.put([42, None, 'hello'])
  File "C:\Users\WYM\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\queues.py", line 82, in put
    if not self._sem.acquire(block, timeout):
PermissionError: [WinError 5] Access is denied.

推荐答案

此问题可能是 Python 3.7 的 已知错误.2

This issue may be a known bug with Python 3.7.2

我遇到了同样的问题,并通过使用 Python 3.7.0 创建新的虚拟环境来修复它

I was experiencing the same issue and fixed it by creating a new virtual environment with Python 3.7.0

这篇关于这个错误的原因是什么:“PermissionError: [WinError 5] Access is denied"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆