(Error) OSError: (WinError 6) 句柄无效,当运行 python manage.py shell 时,我不明白发生了什么?

问题描述 投票:0回答:1

models.py 文件

# Create your models here.
class Flight(models.Model):
    origin = models.CharField(max_length=64)
    destination = models.CharField(max_length=64)
    duration = models.IntegerField(null=False)

然后我在终端中运行 python manage.py shell

python manage.py shell
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.3 -- An enhanced Interactive Python. Type '?' for help.  

In [1]: from flights.models import Flight
Cancelling an overlapped future failed
future: <_OverlappedFuture pending overlapped=<pending, 0x1af989b8430> cb=[BaseProactorEventLoop._loop_self_reading()]>
Traceback (most recent call last):
  File "C:\Users\jaina\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 66, in _cancel_overlapped
    self._ov.cancel()
OSError: [WinError 6] The handle is invalid

发生上述错误,我该如何解决这个问题,请帮忙。

python django
1个回答
0
投票

错误的原因是 Django 5.0 与 Python 3.8 不兼容,要消除此错误只需升级到该语言的兼容版本,Django 5.0 支持 Python 3.10、3.11 和 3.12

此外,Django 4.2。 x系列是最后支持Python 3.8和3.9的,如果你确实需要在Python 3.8或3上开发你的项目。

© www.soinside.com 2019 - 2024. All rights reserved.