views:

563

answers:

1

I wrote

import serial

There message are occured.

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/serial/__init__.py", line 20, in ?
    from serialposix import *
  File "/usr/lib/python2.4/site-packages/serial/serialposix.py", line 13, in ?
    import sys, os, fcntl, termios, struct, select, errno
ImportError: No module named termios

What's wrong?

+3  A: 

termios has been in the Python standard library since 2.0 at least (I'm not very familiar with older Python versions), but it's always been a Unix-only module. Your 2.4 should be fine, IF you're running under any Unix flavor -- i.e., anything but Windows, more or less. The problem you're seeing suggests either a faulty Python install, or that you're on a non-Unix platform (and if it's not Windows I'm very curious to learn what it IS).

Edit: OP has clarified that they're on Debian -- which has a long history of removing some crucial pieces from upstream components and hiding them in hard-to-locate packages, a history that has long hurt their Python packaging in particular.

I tried several package search engines but I can't find out where they hid termios for Python in particular (for any version) so all I can suggest are workarounds (unless the debian tag I just added attracts debian experts who can help) as well of course as asking on debian-specific forums (clarifying exactly what versions are in use, of course).

Maybe installing another Python (a REAL Python, not the "cleverly packaged", i.e. mangled into pieces and with pieces missing, Debian travesty) might help -- for example, if both sticking with Python 2.4 and using .deb are important constraints to the OP, PYTHON2.4_2.4.6-1UBUNTU3_I386.DEB (not sure how cleanly it and its dependencies install on the OP's specific Debian version, of course); or else, one might as well go with a more recent and complete Python, see for example here (specifically for Debian Etch, but hopefully it can be adapted for the OP's exact version).

Alex Martelli
Thanky you so much.I'm using debian with Python 2.4. but there is not termios
ffffff
debian has long had the habit of fragmenting upstream distros into many slivers and hiding some pieces; I have no idea where they hid termios.so from Python 2.4 (or other versions). This is a strictly debian-related problem so I'm going to edit your question to tag it as such and my answer to suggest workarounds.
Alex Martelli
try to locate os.py and termios.py and then see if their paths match. os.py would probably be in /usr/lib/python2.4
mtasic