Python Forum
what to do if moudle not in pip3 only in pip2?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what to do if moudle not in pip3 only in pip2?
#10
Ok
now I don't get this error

but when I try to run the code I get that somehting is wrong with the modem-cmd package


import time
import datetime
import serial
import pynmea2
from modemcmd import modemcmd
from modemcmd import ModemcmdException
from modemcmd import ModemcmdTimeoutException


ser = serial.Serial('/dev/ttyUSB1',9600,timeout = 0.5)
ModemInfo = '/dev/ttyUSB2'

try:
    result = modemcmd('/dev/ttyUSB2', 'AT+CSQ', 2)
except ModemcmdTimeoutException as e:
    print (e)
except ModemcmdException as e:
    print (e)
but I get this error:
Traceback (most recent call last):
  File "GetAllData_test.py", line 20, in <module>
    result = modemcmd('/dev/ttyUSB2', 'AT+CSQ', 2)
  File "/home/pi/.local/lib/python3.7/site-packages/modemcmd/__init__.py", line 26, in modemcmd
    serial.write(cmd)
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 532, in write
    d = to_bytes(data)
  File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 63, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: 'AT+CSQ\r'
Reply


Messages In This Thread
RE: what to do if moudle not in pip3 only in pip2? - by korenron - Oct-24-2021, 02:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ModuleNotFoundError: No module named '_struct' when starting pip3 yuhuihu 0 2,997 May-05-2022, 04:41 AM
Last Post: yuhuihu
  cmake and pip3 install warnings with python 3.10.2 cyrduf 0 1,985 Feb-26-2022, 01:08 PM
Last Post: cyrduf
  pip3 v21.1.2 SSL Error on RHEL 7 malibu 0 3,182 Jun-01-2021, 03:17 PM
Last Post: malibu
  pip3 install opencv-python fails on 'skbuild' Pedroski55 2 5,924 Sep-15-2020, 11:33 AM
Last Post: snippsat
  Install module with pip3 on a non root user matthewpintor2107 1 2,512 Apr-28-2020, 03:16 PM
Last Post: pyzyx3qwerty
  Wrong pip3 python location or new Version 007fred50 1 3,883 Apr-02-2020, 02:36 PM
Last Post: philgoetz
  Call pip3 from python folder build by me call pip3 from the /usr/bin Suryavarman 3 3,812 Oct-07-2019, 10:23 PM
Last Post: Suryavarman
  Installed Python3.7 from package, trying to run pip3.7 does not work JBristow1729 4 7,637 Aug-11-2019, 08:24 AM
Last Post: michaellossagk
  pip3 install functools failed kintarowonders 1 16,085 Mar-07-2019, 07:56 PM
Last Post: nilamo
  What's the difference between pip and pip3? magic 5 48,373 Sep-20-2018, 08:15 PM
Last Post: magic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020