yannbouteiller / vgamepad

Virtual XBox360 and DualShock4 gamepads in python
MIT License
162 stars 21 forks source link

AttributeError: partially initialized module 'vgamepad' has no attribute 'VX360Gamepad' (most likely due to a circular import) #21

Closed constantindjonkam closed 8 months ago

constantindjonkam commented 10 months ago

I'm getting this error after installing the package and attempting to run the script. My code is provided below

import vgamepad as vg

gamepad = vg.VX360Gamepad()

gamepad.press_button(button=vg.DS4_BUTTONS.DS4_BUTTON_TRIANGLE)
gamepad.update()
yannbouteiller commented 10 months ago

Circular import? This is strange, I never got this error with vgamepad, can you provide more information regarding how you are testing this code snippet? Do you get the exception when running only this code snippet in a standalone script? Also can you provide your python version and tell whether you are using Windows or Linux please?

constantindjonkam commented 10 months ago

Yes I get the error only using the provided code snippet in a standalone script. I'm on windows and my python version is 3.11.6.

I got around this by cloning the repo and moving only the folder I needed aka "win" in my project root dir and then updating the import statements accordingly

yannbouteiller commented 10 months ago

I see, thanks, probably this is an issue with the latest version that introduced Linux support, although I haven't encountered it yet. I'll try to see if I can reproduce the issue.

yannbouteiller commented 10 months ago

@constantindjonkam I cannot reproduce the issue, neither with the Anaconda package manager (whose latest available Python version is 3.11.5), nor with a direct installation of 3.11.6 on Windows. Could you be more specific about how you installed Python (and vgamepad) on your Windows machine please?

This is using direct python 3.11.6 installation on Windows 11 and installing vgamepad from pip:

Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vgamepad as vg
>>> gamepad = vg.VX360Gamepad()
>>> gamepad.press_button(button=vg.DS4_BUTTONS.DS4_BUTTON_TRIANGLE)
>>> gamepad.update()
>>>
yannbouteiller commented 8 months ago

Closing for inactivity