Pandas3D无法正确导入ShowBase,我可能做错了什么?

2024-06-07 17:30:07 发布

您现在位置:Python中文网/ 问答频道 /正文

试着和Panda3D一起跑起来。我好像跟ShowBase类没什么关系。你知道吗

我按照网站的指示使用以下代码:

    from direct.showbase.ShowBase import ShowBase

class myApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

app = myApp()
app.run()

现在,当我去测试它时,我得到以下错误:

Traceback (most recent call last):
  File "C:\Users\POWER\Documents\python_programs\panda3d.py", line 1, in <module>
    from direct.showbase.ShowBase import ShowBase
  File "C:\Users\POWER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\showbase\ShowBase.py", line 12, in <module>
    from panda3d.core import *
  File "C:\Users\POWER\Documents\python_programs\panda3d.py", line 1, in <module>
    from direct.showbase.ShowBase import ShowBase
ImportError: cannot import name 'ShowBase' from 'direct.showbase.ShowBase' (C:\Users\POWER\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\showbase\ShowBase.py)

使用windows10、python3.7。有什么帮助吗?你知道吗


Tags: infrompyimportinitlinepanda3dusers
1条回答
网友
1楼 · 发布于 2024-06-07 17:30:07

检查是否安装了Panda3D,如果没有,则转到命令提示符并键入:
pip安装Panda3D

代码中的另一个错误是缩进导入ShowBase时,请尝试使用任何缩进导入。你知道吗

from direct.showbase.ShowBase import ShowBase

如果您还有其他问题,请检查Panda3D Manual

相关问题 更多 >

    热门问题