~ni/nxt-python

ref: 0953c609c26e9183a88c70c95f87980fb85f4277 nxt-python/docs/installation.rst -rw-r--r-- 2.7 KiB
0953c609 — Ralph Hart, Jr docs/installation.rst: add macOS for installing pybluez 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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


On MacOS::

The current PyPi version of pybluez does not work with nxt-python. You will need to a more recent version from GitHub.

Download and install Xcode from App Store or Apple Developer site

Then activate the Xcode installation::

    xcode-select -s /Applications/Xcode.app/Contents/Developer

Then install pybluez from GitHub::

    pip3 install https://github.com/pybluez/pybluez/tarball/07ebef044195331a48bbb90a3acb911922048ba0

As of 06/18/2022, commit 07ebef044195331a48bbb90a3acb911922048ba0 works with nxt-python 3.1.0.