My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Installation  
Installation Instructions
Featured, Phase-Deploy
Updated Jul 30, 2011 by marcus@wanners.net

Installation Instructions

Linux

You will need version 2.6 (or later 2.x) of Python, most modern systems already have this installed. However, as more distributions move to 3.x (which is not compatible with nxt-python), you may need to install version 2.6 in addition (they coexist fine) using your package manager.

Download the latest source package and extract it. Open a terminal and run cd nxt-python (or whatever directory you put it in). Then, as root (e.g. sudo) run python setup.py install. If the word ‘error’ is not anywhere in the text that is printed, then great. If it is, then follow the error instructions to resolve the issue (or ask about it at the mailing list, and we'll try to help you out).

For USB communications, download and install PyUSB according to the instructions included in it. If you're on debian/ubuntu, just run apt-get install python-usb as root. The following step may not be necessary on some newer systems which give any user control over USB devices by default, but it can't hurt and is therefore recommended. As root, run the command groupadd lego, then usermod –a –G lego <username> (where <username> is the name of the user account that you will be using to program your NXT). Then make a file at /etc/udev/rules.d/70-lego.rules containing exactly (note that after this you will need to log out and then back in and then restart udev or your whole system):
SUBSYSTEM=="usb", ATTRS{idVendor}=="0694", GROUP="lego", MODE="0660"
For Bluetooth communications, install PyBluez, or on debian-based systems, you can just run (as root) apt-get install python-bluez. You will also need a compatible Bluetooth dongle, if your computer doesn’t already support Bluetooth.

Windows

You will need Python 2.6 or later (But not 3.x).

Download the latest NXT-Python zipfile from the downloads page and extract it. Go to the new folder and double-click on install.bat. If a black window appears, scrolls some text, and then goes away, the installation succeeded. If it shows an error message and does not go away, there was a problem. If you're not sure if the installation worked, open a python shell and type "import nxt". If it doesn't print any output, things are working fine. Before you get started though, you'll need one of these libraries:

For USB Communication

Download and install PyUSB. USB has a history of being dodgy on Windows, so if the brick can't be found when it should, try bluetooth.

For Bluetooth Communication

Download and install PyBluez. You will also need a compatible Bluetooth dongle, if your computer doesn’t already support Bluetooth.

For LEGO Fantom Driver Communication

Download and install Pyfantom. You will also need to have the fantom driver set up and working.

Mac

To use NXT-Python on Mac, you will need Python 2.6 or higher (but not 3.x).

Make sure you have PyObjC installed; this comes preinstalled with Mac OS X v10.5 (Leopard) and anything newer, but if you have an earlier version of OS X you will need to install it yourself. Then, install LightBlue, a python Bluetooth library for Mac. For USB connections, you will need PyUSB. You can also use the LEGO Fantom Driver, but you'll need to install Pyfantom as well. Note that you only need one of these communications backends, but can install as many as you want.

Download the latest source package from the downloads page and extract it. Open a terminal, move to the nxt-python directory using cd nxt-python (or whatever directory you put it in), and run python setup.py install. To test the installation, run one of the programs in the examples directory.

What if I already have LightBlue Glue installed with an older version of nxt-python or NXT_Python?

If you have an existing LightBlue Glue setup, you can update by doing the following:

Follow the instructions above. After doing that, remove your bluetooth.py directory (~/nxt_lightblue_glue in the setup example) and the PYTHONPATH line to that you added to your .profile or .bashrc.

Note that if you do not delete the bluetooth.py directory or PYTHONPATH enrty, NXT-Python should still work fine, it will just use the external LightBlue Glue instead of the new internal one.

Checking out the SVN to get the latest development version

You will need to download an SVN client for your OS. For linux, the standard command line one works great. For Windows, I use TortoiseSVN. For Mac, I would suggest Google. After you get SVN working on your system, follow Google's instructions as far as the URL goes. Once you have a source tree, follow the installation instructions in the README (which basically amount to running python setup.py install).

Then What?

Now that you have successfully installed NXT_python and one or more of the communication packages (PyUSB, PyBluez, or LightBlue), you can start using your nxt brick.

See the tutorial page or the examples in the examples folder for usage instructions.

Comment by torsten....@hamburg.de, Apr 24, 2010

On a Mac, you just copy and paste the svn code to a Terminal window - et voilà, the code downloads. svn checkout http://nxt-python.googlecode.com/svn/trunk/ nxt-python-read-only

Comment by project member marcus@wanners.net, Apr 24, 2010

Thank you for letting me know, can you tell me how the rest of the installation went as well? I've been needing someone to test the mac instructions for a while now...

Comment by Tully.Foote, Jun 3, 2010

On Ubuntu Karmic there is a slightly different syntax for the udev rules. I successfully used the following.

BUS=="usb", ATTRS{idVendor}=="0694", GROUP="lego", MODE="0660"

Also note you need to logout to get your group permissions updated. And you need to restart the udev service to get the new rules to take.

Comment by project member marcus@wanners.net, Jun 3, 2010

I have updated the page to reflect this.

Comment by madjesti...@gmail.com, Aug 31, 2010

Hey guys,

Can somebody tell what's the average Blue Tooth response time between, say, sampling a sensor/motor and data appearing in the terminal? Preferably for OSX, but any would do. I intend to use the brick as a joystick kind of input device and afraid that latency can be too high..

Thanks

Comment by project member marcus@wanners.net, Aug 31, 2010

While I can't really tell you off the top of my head and don't have time to test now, I think it's around 50-100ms (though my memory may have just made that up). It should be low enough for use as a joystick, especially seeing as the Wii uses bluetooth to connect to its controllers and that works fine.

I will do tests and get back to you by today or tomorrow. Thanks for the interesting question!

Comment by project member marcus@wanners.net, Sep 1, 2010

Here are my test results:

                          Bluetooth      USB
Motor Tachometer sample   40 ms          4.0 ms
Digital sensor sample     100 ms         30 ms
Analog Sensor sample      40 ms          4.0 ms

As you can see, a digital sensor (I used a stock ultrasonic one) is noticeably slower than others on bluetooth because one needs to go back and forth over bluetooth while waiting for the I2C bus to be ready. There is not much that can be done about this, though...it's already been optimized quite a bit. Additionally, I included USB results to try to get you to switch to a wired connection since it will have less latency than wireless. However, bluetooth should be fine as 100ms is still only 1/10 of a second...an imperceptible period for most people. I remember one project where I took Wiimote input over bluetooth, bounced it around inside the computer between I think 3 programs using the local loopback interface, and then sent it out to the NXT with nxt-python over bluetooth for a neat, motion-controlled RC car. Even with the latency nightmare that 2 wireless and at least 2 wired connections caused, there was no noticeable lag. Judging from that, I think that the latency for one wireless connection will work just fine for you. Good luck!

On a side note, I did this using the v2 beta, so results may be different with 1.x releases.

And as a disclaimer: Your results may vary due to the number of 2.4GHz devices operating in the area, USB cable length, whether or not your microwave leaks, ionospheric conditions, and other stuff like that. Or to put it more succinctly: YMMV.

Again, thanks for the interesting question and I hope your project works out...sounds fun!

Comment by joseph.m...@gmail.com, Jan 30, 2011

Can someone point to instructions for installing this on a 64 bit Windows 7 install? It's pretty obscure as to which versions of PyUSB, PyBluez?, and libusb you need for a system like this.

Comment by project member marcus@wanners.net, Jan 30, 2011

You should use the Win64 executable installer for nxt-python

-OR-

Download the source and double-click install.bat. This last option is better because you get the examples and README file saved somewhere.

As for PyUSB and PyBluez?, the latest version should be fine unless they've broken the API recently in which case you should get the version with the older API. But I doubt they have. Just look for "64-bit" in the installers and you should be good.

Comment by carl.in...@gmail.com, Mar 30, 2011

Just noticed that the title of this thread has a typo.

Comment by zbuh...@gmail.com, Jul 30, 2011

Googlecode automagically de-formats my pastes, so I'll have to paste this to a proper pastebin (apologies in advance):

http://paste.pocoo.org/show/449499/

What am I doing wrong?

Comment by project member marcus@wanners.net, Jul 30, 2011

Please ask on the mailing list.

NXT-Python has no C code in it and so can't segfault. I'd check with the pyusb people if that's the backend you're using (as it appears from your paste).

Sorry you're having issues!

Comment by ivanovsk...@gmail.com, Jan 4, 2012

Hello everybody,

I'm working on NXT project and having troubles to install Pyfantom on my machine (working under Win7 - required for project). Could anyone provide me with some instruction how to install Pyfantom under windows? Thank you in advance! Iryna

Comment by project member marcus@wanners.net, Jan 4, 2012

You're really asking in the wrong place. pyfantom is a separate project and is not maintained by the nxt-python developers. http://pyfantom.ni.fr.eu.org/ is the place to look for people who can help you. Sorry you're having issues!

Comment by iqbal...@gmail.com, Jan 17, 2012

I've been using nxt-python successfully for a while using Win7 (thanks for this fantastic project!). I'm trying to move over to a Mac (Snow Leopard). LightBlue? is causing me a lot of grief :( Has anyone gotten this to work recently?

Comment by iqbal...@gmail.com, Jan 17, 2012

Made it work (on Snow Leopard)! I was having trouble installing lightblue. Here are steps I followed in case it helps anyone else:

1) For Mac OS 10.6, you need to modify the lightblue source a bit. Just follow the instructions they provided. 2) You need to have a few extra things in your python path. This wasn't in the instructions for lightblue. I added this to my .profile file:

PYTHONPATH="/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC:/Library/Python/2.6/site-packages" export PYTHONPATH

Note: The above is for reference only. I have python 2.6.6 and these paths worked for me. You might have different paths. One way to verify lightblue is working is to start up python, and then import lightblue. If it works without an error, you are good to go. Note 2: I wasn't sure if I had to reinstall nxt-python after installing lightblue but I did it just to be safe.

2.5) If you had previously paired the NXT with anothoer machine, make sure to break that connection. (DOH!) 3) Make sure Bluetooth is turned on (Go to Settings)

Note 3: I know the Synchronized Motor class is experimental. It was working quite well on Windows. On the Mac, it is jerking at the end of the command. Will continue to experiment.


Sign in to add a comment
Powered by Google Project Hosting