Python Forum
what to do if moudle not in pip3 only in pip2? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: what to do if moudle not in pip3 only in pip2? (/thread-35361.html)

Pages: 1 2 3


RE: what to do if moudle not in pip3 only in pip2? - snippsat - Oct-25-2021

(Oct-25-2021, 11:14 AM)korenron Wrote: *** up until now on all the code I wrote , I allways used python3 only in the command line
Then you have been using old python3 version that comes with OS.
Type python3 in command line and i guess Python 3.5 interpreter start.
Then exit() and type python3.7.
When install with pip3 install modemcmd it will install to Python 3.7(then you most use this version).
Try to install modemcmd again
Then from command line python3.7 ,as i show under here.
Here i use virtual environment that made before, see that both modemcmd and serial works.
>>> from modemcmd import modemcmd
>>> import serial
>>>
>>> modemcmd
<function modemcmd at 0x000001CCDA68D670>

>>> serial.__version__
'3.5'
>>> exit()



RE: what to do if moudle not in pip3 only in pip2? - korenron - Oct-25-2021

 python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
python3.7
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
 pip3 install modem-cmd
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: modem-cmd in ./.local/lib/python3.7/site-packages (1.0.2)
Requirement already satisfied: pyserial>=2.6 in /usr/lib/python3/dist-packages (from modem-cmd) (3.4)
same error:

python3.7
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from modemcmd import modemcmd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/modemcmd/__init__.py", line 2, in <module>
    from serial import Serial
ModuleNotFoundError: No module named 'serial'
I have try to reinstall serail\pyserial - but it said thery are there
pip3 install serial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: serial in ./.local/lib/python3.7/site-packages (0.0.97)
Requirement already satisfied: iso8601>=0.1.12 in ./.local/lib/python3.7/site-packages (from serial) (0.1.16)
Requirement already satisfied: pyyaml>=3.13 in ./.local/lib/python3.7/site-packages (from serial) (6.0)
Requirement already satisfied: future>=0.17.1 in ./.local/lib/python3.7/site-packages (from serial) (0.18.2)
pi@raspberrypi:~ $ pip3 install pyserial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (3.4)



RE: what to do if moudle not in pip3 only in pip2? - snippsat - Oct-25-2021

Something is messed up.
Requirement already satisfied: modem-cmd in ./.local/lib/python3.7/site-packages (1.0.2)
Requirement already satisfied: pyserial>=2.6 in /usr/lib/python3/dist-packages (from modem-cmd) (3.4)
See that it also mention /usr/lib/python3

And you shall not do pip3 install serial that and other old package(can make trouble) that's not pyserial 3.5
The only install needed is pip3 install modem-cmd(will install also pyserial 3.5)

Don't what to help with now something is messed up other that suggested virtual environment.
# Make 
python3.7 -m venv modem_env

# Cd in
cd modem_env/

# Activate see that it say (modem_env) first now
source bin/activate
 
# Install
pip3 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
Test that i works python3.7 for you
$ 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
>>> import serial
>>> 
>>> modemcmd
<function modemcmd at 0x7f774ea65ee0>
>>> 
>>> serial.__version__
'3.5'
>>> exit()
Can also look at pyenv Simple Python Version Management.
That what i use then it easy to install versions,as Python3.7 start to get old now.