~ni/nxt-python

ref: c58968aa489da319f0d0d07d98509393b334a424 nxt-python/docs/installation.rst -rw-r--r-- 2.2 KiB
c58968aaNicolas Schodet Ran isort, black and flake8 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Installation
============

Install NXT-Python with :command:`pip`::

    python3 -m pip install --upgrade nxt-python

To check that NXT-Python is correctly installed, connect your NXT brick using
a USB cable, and run::

    nxt_test

In case of problem, enable debugging for extra diagnostics::

    nxt_test --log-level=debug


USB
---

USB support is provided by PyUSB which is installed automatically with
NXT-Python. You can also use the package from your Linux distribution if you
wish, in this case, install it before installing NXT-Python.

PyUSB requires libusb or OpenUSB running on your system.

- For Linux users, you can install it from your package manager if not
  installed yet.
- For MacOS users, you can use ``brew install libusb`` to install it using
  Homebrew.
- For Windows users, libusb 1.0 DLLs are provided in the releases. Check the
  `PyUSB FAQ`_.

.. _PyUSB FAQ: https://github.com/pyusb/pyusb/blob/master/docs/faq.rst#how-do-i-install-libusb-on-windows


USB access permissions for Linux
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You need to allow connection to the NXT brick for your user. If you install
any package interacting with the NXT brick from your distribution, this is
usually already done for you (for example, nbc, or libnxt).

In other cases, copy `contrib/60-libnxt.rules` from the NXT-Python source
distribution to your `/etc/udev/rules.d` directory, then make sure that udev
see the change: restart your computer or use the following commands::

    sudo udevadm control --reload
    sudo udevadm trigger


Bluetooth
---------

NXT-Python is only installed with USB by default, you need to install
Bluetooth support explicitly.


Installation from Linux Distribution Package
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The easiest solution is to install PyBluez from your distribution.

On Debian based distributions, like Ubuntu::

    apt install python3-bluez

On ArchLinux::

    pacman -S python-pybluez

On Fedora::

    dnf install python3-bluez


Installation Using Pip
^^^^^^^^^^^^^^^^^^^^^^

You can install PyBluez using :command:`pip`. This is easy if there is a
pre-build package for your system and python version. This is much harder if
this is not the case.

Try this::

    python3 -m pip install PyBluez