yannbouteiller / vgamepad

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

VIGEM_ERROR_BUS_NOT_FOUND #4

Closed vlad-ulmeanu01 closed 2 years ago

vlad-ulmeanu01 commented 3 years ago

Hi, this is a great project! However, I've gotten into some trouble trying to install it.

With Windows 10 64 bit, python 3.7.1 (32-bit), pip 21.1.3, after successfully running pip install vgamepad, trying to import vgamepad results in the following error messages:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Mi Notebook Pro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vgamepad\__init__.py", line 1, in <module>
    from vgamepad.win.virtual_gamepad import VX360Gamepad, VDS4Gamepad
  File "C:\Users\Mi Notebook Pro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vgamepad\win\virtual_gamepad.py", line 32, in <module>
    VBUS = VBus()
  File "C:\Users\Mi Notebook Pro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vgamepad\win\virtual_gamepad.py", line 21, in __init__
    check_err(vcli.vigem_connect(self._busp))
  File "C:\Users\Mi Notebook Pro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\vgamepad\win\virtual_gamepad.py", line 12, in check_err
    raise Exception(vcom.VIGEM_ERRORS(err).name)
Exception: VIGEM_ERROR_BUS_NOT_FOUND

I have since succeded in installing vgamepad on another Windows 10 64 bit machine (python 3.9.7 64-bit, pip 21.0.1).

Could this be because of a difference between 32-bit and 64-bit versions? Also, the username on the machine with the failed attempt has spaces in it, while the other one doesn't.

I have tried pip uninstall vgamepad to reinstall it again, but still had the same problem. While reinstalling I didn't have to redo the ViGEmBus driver part.

What could be the problem? Thank you very much!

yannbouteiller commented 3 years ago

Hi! Mmh I don't know, we already had an issue with people trying to use python 32 bits but it is supposed to be fixed in current versions of the library. Could you try with a 64 bits version of python on the machine on which you get the bug please?

To see whether this is the python version or something else; but according to your error vigem-client did not find vigembus installed on your machine, the guy in this related issue https://github.com/sam0x17/XJoy/issues/48 seems to have fixed their issue by reinstalling vigembus but I don't see why this should work the second time (caution: they use an older version of vigembus, vgamepad uses 1.17.333).

Could you also try to uninstall vigembus (nefarius solutions, should be version 1.17.333) manually from your PC, then pip uninstall vgamepad, and then pip install vgamepad again?

vlad-ulmeanu01 commented 3 years ago

Hi, couldn't figure out how to uninstall vigembus, so just ran the installer again. While the x86 one crashed, the x64 one completed successfully again. This time import vgamepad worked!

I am still running it with 32 bit python, I could change it if you would want to test that too.

Thank you for the great library, now I'm the owner of a working potentiometer as a steering wheel)))

yannbouteiller commented 3 years ago

Cool I'm glad that's fixed :)

I might understand what happened, I'm not sure. When you pip install vgamepad, this script is executed, and I call platform.architecture() to determine whether your system is 32 or 64 bits, so as to determine what vigembus installer should be executed. Maybe this is a mistake and it actually returns the architecture of the python interpreter instead of that of the PC?

To fix the problem, you ran the x64 installer by downloading it directly from the vigembus github?

vlad-ulmeanu01 commented 2 years ago

Yes! It turns out platform.architecture() returns the type of the python interpreter:

>>> platform.architecture()
('32bit', 'WindowsPE')

I think that you want something like this instead of lines 9-12 in setup.py:

arch = "x" + platform.machine()[-2:]
assert(arch in ("x64", "x86"))

(https://stackoverflow.com/questions/2208828/detect-64bit-os-windows-in-python)

I ended up searching through the whole system for "vigembus", and reran the installer that pip provided. Not sure if you can fix this, but pip uninstall vgamepad doesn't erase the vigembus installers, so they end up downloaded one more time upon reinstalling.

Also, sorry for the late response! It also seems that the project was well received))) https://www.reddit.com/r/redneckengineering/comments/pwfgyb/new_steering_wheel_just_came_in/

yannbouteiller commented 2 years ago

Cool! thanks for the solution, I'll fix that.

The vigembus installer is part of the vgamepad library, it is downloaded by pip where pip installs vgamepad (and both the x86 and x64 installers are downloaded)

(Wow, the project looks impressive, congrats!)

yannbouteiller commented 2 years ago

This should be fixed in 0.0.4 :)

yannbouteiller commented 2 years ago

Although I am not quite sure why the 32 bits installer didn't work on your 64 bits machine.