Brikwerk / nxbt

Control your Nintendo Switch through a website, terminal, or macro.
MIT License
815 stars 100 forks source link

Missing module error during installation #161

Open jaherron opened 1 month ago

jaherron commented 1 month ago

Device: Raspberry Pi 5 (8GB RAM) OS: Ubuntu 24.04.1 Python Version: 3.12.3 pipx version: 1.4.3

I got the externally-managed error when installing nxbt, so I tried using pipx as instructed by pip. It's throwing an error about a missing module called "imp".

Output from pipx (verbose)

pipx >(setup:860): pipx version is 1.4.3
pipx >(setup:861): Default python interpreter is '/usr/bin/python3'
pipx >(package_name_from_spec:370): Determined package name: nxbt
pipx >(package_name_from_spec:371): Package name determined in 0.0s
creating virtual environment...
pipx >(run_subprocess:168): running /usr/bin/python3 -m venv --without-pip /root/.local/share/pipx/venvs/nxbt
pipx >(run_subprocess:168): running <checking pip's availability>
pipx >(run_subprocess:168): running /root/.local/share/pipx/venvs/nxbt/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:168): running /root/.local/share/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:168): running /root/.local/share/pipx/venvs/nxbt/bin/python --version
pipx >(_parsed_package_to_package_or_url:137): cleaned package spec: nxbt
installing nxbt...
pipx >(run_subprocess:168): running /root/.local/share/pipx/venvs/nxbt/bin/python -m pip --no-input install nxbt
pipx >(subprocess_post_check_handle_pip_error:327): '/root/.local/share/pipx/venvs/nxbt/bin/python -m pip --no-input install nxbt' failed
pipx >(subprocess_post_check_handle_pip_error:342): Fatal error from pip prevented installation. Full pip output in file:
    /root/.local/state/pipx/log/cmd_2024-09-19_20.07.10_pip_errors.log

pipx >(analyze_pip_output:298): pip failed to build package:
    dbus-python

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    ModuleNotFoundError: No module named 'imp'
    subprocess.CalledProcessError: Command '['make', '-C', '/tmp/pip-install-kcg4ox58/dbus-python_90a2c3c19b8d48d0bcc277df4d361875/build/temp.linux-aarch64-cpython-312', 'install', 'pythondir=/tmp/pip-install-kcg4ox58/dbus-python_90a2c3c19b8d48d0bcc277df4d361875/build/lib.linux-aarch64-cpython-312', 'pyexecdir=/tmp/pip-install-kcg4ox58/dbus-python_90a2c3c19b8d48d0bcc277df4d361875/build/lib.linux-aarch64-cpython-312']' returned non-zero exit status 2.
    ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (dbus-python)

pipx >(rmdir:55): removing directory /root/.local/share/pipx/venvs/nxbt
Error installing nxbt.
RPGillespie6 commented 1 month ago
ModuleNotFoundError: No module named 'imp'

Is likely because you are on python 3.12. Downgrade to 3.11 or clone repo instead of using pip.

Raziiel4899 commented 4 weeks ago
ModuleNotFoundError: No module named 'imp'

Is likely because you are on python 3.12. Downgrade to 3.11 or clone repo instead of using pip.

i'm new to this and google isn't really helping me here, what's the command to downgrade to 3.11 ? i've been looking for it for days and i can't find it...

RPGillespie6 commented 4 weeks ago

Depends, what's your linux distro? Probably easiest way is to just continue to use python 3.12, but clone the repo to use it instead of installing from pypi

Raziiel4899 commented 4 weeks ago

Depends, what's your linux distro? Probably easiest way is to just continue to use python 3.12, but clone the repo to use it instead of installing from pypi

I'm on linux mint, i cloned the repo and now idk what to do with it

RPGillespie6 commented 4 weeks ago

Well, start with running the demo:

python3 demo.py

Looks like the general entrypoint is cli.py in the nxbt folder so you could also try

python3 nxbt/cli.py demo
jaherron commented 4 weeks ago

I did author PR #162 to update the dependencies that were causing the issue, and I tested and confirmed that the software still worked. I just don't know if any maintainers saw it yet.

Raziiel4899 commented 4 weeks ago

Well, start with running the demo:

python3 demo.py

Looks like the general entrypoint is cli.py in the nxbt folder so you could also try

python3 nxbt/cli.py demo

i'm getting this error :

Traceback (most recent call last):
  File "/home/raziiel/nxbt/demo.py", line 63, in <module>
    nx = nxbt.Nxbt()
         ^^^^^^^^^^^
  File "/home/raziiel/nxbt/nxbt/nxbt.py", line 181, in __init__
    toggle_clean_bluez(True)
  File "/home/raziiel/nxbt/nxbt/bluez.py", line 131, in toggle_clean_bluez
    override_dir.mkdir(parents=True, exist_ok=True)
  File "/usr/lib/python3.12/pathlib.py", line 1313, in mkdir
    os.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/run/systemd/system/bluetooth.service.d'

same with python3 nxbt/cli.py demo

RPGillespie6 commented 4 weeks ago

Try running with sudo. Also, you may just want to take some time to learn python and linux in general, it will help you greatly in troubleshooting these types of issues.

RPGillespie6 commented 4 weeks ago

I did author PR #162 to update the dependencies that were causing the issue, and I tested and confirmed that the software still worked. I just don't know if any maintainers saw it yet.

Nice, yeah I wonder if this project is somewhat dead-ish.

Raziiel4899 commented 4 weeks ago

it doesn't seem to do anything?

UPDATE : it worked i had to restart my switch for some reason, now the only problem i have is cli.py not working

image

RPGillespie6 commented 4 weeks ago

I got it to work by creating a file in the repo root called test.py containing:

import nxbt

RETURN_TO_GAME_MACRO = """
6s
A 0.1s
1s
B 0.1s
1s
B 0.1s
1s
HOME 0.1s
1s
"""

# Start the NXBT service
nx = nxbt.Nxbt()

# Create a Pro Controller and wait for it to connect
print("Connecting... ensure you are on 'Change Grip/Order' screen")
controller_index = nx.create_controller(nxbt.PRO_CONTROLLER)
nx.wait_for_connection(controller_index)
print("Connected!")

print("Running macro to return to game...")
nx.macro(controller_index, RETURN_TO_GAME_MACRO)

And then I ran sudo python3 test.py

You might also have luck making the change @jaherron made in his PR here: https://github.com/Brikwerk/nxbt/pull/162/files and then doing pip install -e .

Raziiel4899 commented 4 weeks ago

got this

image

update : removed some lines and ig it worked..?

image

update again : after everything, it doesn't seem to work? i'm kinda lost on what to do now