Posts: 257 Threads: 108 Joined: May 2019 Oct-24-2021, 12:21 PM (This post was last modified: Oct-24-2021, 12:26 PM by korenron.) I'm trying to use modemcmd I can only install it using pip install when I ty to use pip3 install modemcmd I get : Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting modemcmd Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/modemcmd/ so what will be a good solution for this problem? Thanks, Posts: 1,835 Threads: 2 Joined: Apr 2017 Looks like you don't have the library installed. Did you also try to install it? Posts: 7,398 Threads: 123 Joined: Sep 2016 It's like this. pip3 install modem-cmd Posts: 257 Threads: 108 Joined: May 2019 Oct-24-2021, 12:52 PM (This post was last modified: Oct-24-2021, 01:30 PM by korenron.) I'm getting this error now python3 GetAllData_Working_backup.py Traceback (most recent call last): File "GetAllData_Working_backup.py", line 5, in <module> from modemcmd import modemcmd File "/home/pi/.local/lib/python3.7/site-packages/modemcmd/__init__.py", line 2, in <module> from serial import Serial ImportError: cannot import name 'Serial' from 'serial' (/home/pi/.local/lib/python3.7/site-packages/serial/__init__.py) this is the full code , I have only import the wanted packages import asyncio import websockets import time import datetime import serial import pynmea2 from modemcmd import modemcmd from modemcmd import ModemcmdException from modemcmd import ModemcmdTimeoutException from gpiozero import CPUTemperature ser = serial.Serial('/dev/ttyUSB1',9600,timeout = 0.5) ModemInfo = '/dev/ttyUSB2' Posts: 7,398 Threads: 123 Joined: Sep 2016 Oct-24-2021, 01:28 PM (This post was last modified: Oct-24-2021, 01:29 PM by snippsat.) It now read from wrong package,it shall read from pyserial and then sub-folder serial. Rename or delete python3.7/site-packages/ serial/ folder and try again. You could of course use virtual environment,it's build into Python and then will avoid conflict like this. Example. tom@tom:~$ python -m venv modem_env tom@tom:~$ cd modem_env/ tom@tom:~/modem_env$ source bin/activate (modem_env) tom@tom:~/modem_env$ pip install modem-cmd Collecting modem-cmd Downloading modem-cmd-1.0.2.tar.gz (2.2 kB) Collecting pyserial>=2.6 Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB) |████████████████████████████████| 90 kB 1.6 MB/s Using legacy 'setup.py install' for modem-cmd, since package 'wheel' is not installed. Installing collected packages: pyserial, modem-cmd Running setup.py install for modem-cmd ... done Successfully installed modem-cmd-1.0.2 pyserial-3.5 (modem_env) tom@tom:~/modem_env$ python Python 3.9.6 (default, Aug 3 2021, 16:49:17) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from modemcmd import modemcmd >>> >>> modecmd <function modemcmd at 0x7f6c98baaf70> Posts: 257 Threads: 108 Joined: May 2019 (Oct-24-2021, 01:28 PM)snippsat Wrote: It now read from wrong package,it shall read from pyserial and then sub-folder serial. Rename or delete python3.7/site-packages/serial/ folder and try again. how do I do this? ** it's seem like a easier option Thanks, Posts: 7,398 Threads: 123 Joined: Sep 2016 Posts: 257 Threads: 108 Joined: May 2019 I just want to be sure I will remove this folder using rm python3.7/site-packages/serial/ then install using pip3 install pyserial is this correct? Posts: 7,398 Threads: 123 Joined: Sep 2016 rm -r /home/pi/.local/lib/python3.7/site-packages/serial/ (Oct-24-2021, 01:45 PM)korenron Wrote: then install using pip3 install modem-cmd dos install pyserial. Look at my demo before where i install it. snippsat Wrote:Successfully installed modem-cmd-1.0.2 pyserial-3.5 Posts: 257 Threads: 108 Joined: May 2019 Oct-24-2021, 02:37 PM (This post was last modified: Oct-24-2021, 02:37 PM by korenron.) 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' |