python RuntimeError:cannot join current thread 错误:无法加入当前进程

笔者环境 python3.7+tqdm4.28.1

在运行程序的时候老是会报错

RuntimeError:cannot join current thread

原因:参考_1,参考_2

解决方法:

定位到你安装的tqdm包,一般都是安装在site-packages/tqdm中,然后找到_monitor.py文件,打开在以下内容中做出修改

from threading import Event,Thread,current_thread #第一行修改为这样
.
.
.
def exit(self):                                   #50行之后的exit函数修改为这样
        self.was_killed.set()
        if self is not current_thread():
            self.join()
        return self.report()

很奇怪,当我在win10中查找的_monitor文件时已经修改好了的,可能是4.31.1新版本已经修改好了这个bug,但是tensorflow环境下的版本应该还是会出问题。

(base) C:\Users\Lenovo>activate tensorflow

(tensorflow) C:\Users\Lenovo>python
Python 3.6.7 |Anaconda, Inc.| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tqdm
>>> tqdm.__version__
'4.28.1'
>>> exit()

(tensorflow) C:\Users\Lenovo>activate torch

(tensorflow) C:\Users\Lenovo>conda.bat activate torch

(torch) C:\Users\Lenovo>python
Python 3.6.8 |Anaconda, Inc.| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tqdm
>>> tqdm.__version__
'4.31.1'
>>>

可能是新版本的tqdm(4.31.1)已经修改好了这个bug

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值