ImportError: cannot import name 'ShowBase'

Hi I new in this community so Hello yo everybody. And excuse my poor english, it’s not my native language.
I not new with panda3D, but normally I used linux. This time I try to install under windows 10.

I only have pyton 3.7, and I install panda3D using PIP

pip install panda3D

After the installation, I tried the hello world under Ipython console and work great.

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In 1: from direct.showbase.ShowBase import ShowBase

In 2:

But, when I try to import ShowBase from a script under .py file or when try under normal python console I have the next error:

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from direct.showbase.ShowBase import ShowBase
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Usuario\AppData\Local\Programs\Python\Python37\lib\site-packages\direct\showbase\ShowBase.py", line 12, in <module>
    from panda3d.core import *
  File "C:\afrodita\python\panda3d\panda3d.py", line 7, in <module>
    from direct.showbase.ShowBase import ShowBase
ImportError: cannot import name 'ShowBase' from 'direct.showbase.ShowBase' (C:\Users\Usuario\AppData\Local\Programs\Python\Python37\lib\site-packages\direct\showbase\ShowBase.py)

If " from direct.showbase.ShowBase import ShowBase" work under Ipython but not under python shell, I think I have a installation problem. I searched Google for hours, but I couldn’t find any similar problems.

I tried to add "C:\Users\Usuario\AppData\Local\Programs\Python\Python37\lib\site-packages" under “path” variable but it does not work.

Hello, welcome!

The problem is that you named your own file panda3d.py. This conflicts with the panda3d package. When importing panda3d.core, Python ends up actually loading your panda3d.py file instead of the panda3d package, which causes an import loop.

Just rename your panda3d.py to something else and it should work.

1 Like

The classic example of spending hours looking for a solution and in the end is something so simple.

thank very much.