Reputation: 41
While importing serial, I get the following error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
import serial # library for communicating through Serial (used to connect to Arduino)
File "/usr/local/lib/python2.7/dist-packages/serial/__init__.py", line 1, in <module>
from serial import properties, meta, model, utilities, errors
File "/usr/local/lib/python2.7/dist-packages/serial/properties.py", line 7, in <module>
from serial import meta, model
File "/usr/local/lib/python2.7/dist-packages/serial/meta.py", line 12, in <module>
from serial import model
File "/usr/local/lib/python2.7/dist-packages/serial/model.py", line 15, in <module>
from serial import properties, meta
ImportError: cannot import name properties
I have installed the package. I cannot figure it out. Please help.
Upvotes: 2
Views: 4414
Reputation: 11526
Looks like you want to use pyserial
, but pyserial has no properties.py
, no meta.py
and no model.py
, see: https://github.com/pyserial/pyserial/tree/master/serial so the stacktrace you're showing does not come from pyserial.
So there's a conflict between another package and pyserial.
The day to day solution to isolate work environments in Python is to use virtual environment, like:
$ cd /tmp/
$ mkdir -p ~/.venvs/
$ python3 -m venv ~/.venvs/my_project_using_pyserial/
$ . ~/.venvs/my_project_using_pyserial/bin/activate
(my_project_using_pyserial) $ python3 -m pip install pyserial
Collecting pyserial
Downloading pyserial-3.4-py2.py3-none-any.whl (193kB)
100% |████████████████████████████████| 194kB 2.2MB/s
Installing collected packages: pyserial
Successfully installed pyserial-3.4
(my_project_using_pyserial) $ python3
Python 3.5.4 (default, Aug 12 2017, 14:08:14)
[GCC 7.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> dir(serial)
['CR', 'EIGHTBITS', 'FIVEBITS', 'LF', 'PARITY_EVEN', 'PARITY_MARK', 'PARITY_NAMES', 'PARITY_NONE', 'PARITY_ODD', 'PARITY_SPACE', 'PosixPollSerial', 'SEVENBITS', 'SIXBITS', 'STOPBITS_ONE', 'STOPBITS_ONE_POINT_FIVE', 'STOPBITS_TWO', 'Serial', 'SerialBase', 'SerialException', 'SerialTimeoutException', 'Timeout', 'VERSION', 'VTIMESerial', 'XOFF', 'XON', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'basestring', 'importlib', 'io', 'iterbytes', 'os', 'portNotOpenError', 'protocol_handler_packages', 'serial_for_url', 'serialposix', 'serialutil', 'sys', 'time', 'to_bytes', 'unicode', 'writeTimeoutError']
Upvotes: 1