Installing raspberrypi os with inbuilt python 3.7.4 version

Hi guys,
I’m a beginner in using raspberrypi. Basically I want to install raspbian os which has inbuilt python 3.7.4 version. Till now I have found many os having 3.7.3, 3.9.2 (in raspbian os) or 3.10.4 (in ubuntu server) version of python. I tried to use pyenv which installed 3.7.4 but when i tried running my py code after installing all the required libraries I got error saying the required libraries are not found.
So I went with installing python 3.7.4 from scratch as mentioned in the link (by changing 3.9.5 to 3.7.4) https://raspberrytips.com/install-latest-python-raspberry-pi/
After following the steps I made 3.7.4 default version but somehow I got error in using pip command. I re-installed pip but got the same error.
I’m a bit frustrated now as I couldn’t install python 3.7.4. If there is an raspbian os with inbuilt 3.7.4 python version it’ll be great for me to run my code. Or if u guys can guide me to install 3.7.4 and make it default version without any errors I’d be delighted.
Thanks in advance.

1 Like

Hey James
So I followed all the steps as in the website https://raspberrytips.com/install-latest-python-raspberry-pi/ and changed 3.9.2 to 3.7.4, it actually worked and i got to see python 3.7.4 after running code python --version.
But after installing python while I tried to access pip it was pip3.7 and I ran it to see the list below is the error I got

pi@raspberrypi:/ $ pip3.7 list
Package  Version
———- ——-
pip    19.0.3 
setuptools 40.8.0 
Traceback (most recent call last):
 File “/usr/local/bin/pip3.7”, line 10, in <module>
  sys.exit(main())
 File “/usr/local/lib/python3.7/site-packages/pip/_internal/__init__.py”, line 78, in main
  return command.main(cmd_args)
 File “/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py”, line 228, in main
  timeout=min(5, options.timeout)
 File “/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py”, line 93, in _build_session
  insecure_hosts=options.trusted_hosts,
 File “/usr/local/lib/python3.7/site-packages/pip/_internal/download.py”, line 344, in __init__
  self.headers[“User-Agent”] = user_agent()
 File “/usr/local/lib/python3.7/site-packages/pip/_internal/download.py”, line 108, in user_agent
  zip([“name”, “version”, “id”], distro.linux_distribution()),
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 120, in linux_distribution
  return _distro.linux_distribution(full_distribution_name)
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 675, in linux_distribution
  self.version(),
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 735, in version
  self.lsb_release_attr(‘release’),
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 892, in lsb_release_attr
  return self._lsb_release_info.get(attribute, ”)
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 550, in __get__
  ret = obj.__dict__[self._fname] = self._f(obj)
 File “/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py”, line 998, in _lsb_release_info
  stdout = subprocess.check_output(cmd, stderr=devnull)
 File “/usr/local/lib/python3.7/subprocess.py”, line 395, in check_output
  **kwargs).stdout
 File “/usr/local/lib/python3.7/subprocess.py”, line 487, in run
  output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.

So what to do now??
Thanks in advance.

1 Like

Hi Jay
If you do a fresh install of Raspberry Pi OS you will have python version 3.9.2 installed. I am curious why you want to regress to Raspbian and python version 3.7.4.

1 Like

Well I have a python code which will run on 3.7.4. I need it for completing a project. The code ran on windows but I need to interface hardware based on results by the code.

1 Like

Still curious. If you run the code on python 3.9.2 what errors do you see? What python libraries does the code use?

1 Like

Hey Fractal
well I have a code of tensorflow to be run in 3.7 as I already had run it. I have another code which uses face recognition and as u said i downloaded all the libraries required in 3.9.2 but when i try to run it I’m getting error as

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/home/pi/Downloads/pa.py", line 3, in <module>
    import imutils
ModuleNotFoundError: No module named 'imutils'

So it’s not just this library but all the others too. Help me find a solution for this. Thanks

1 Like

Thonny under Tools >> Manage packages is good at finding and installing python packages from different sources.
I easily found the imutils, pygame and tensorflow libraries on PyPi.
So for the error you report there should be something like this at the beginning of the code:
from imutils import *
Thonny is pre-installed on your raspberry pi. There is also a version for Windows.
My suggestion is to use the latest versions of the Raspberry Pi OS and python to get your code running. If the libraries are installed from PyPi then apt-get upgrade will keep them updated. If you get code errors there are probably pygame and tensorflow communities that can help.

1 Like

Alright I’ll check what u said
One doubt does the code ‘from imutil import *’ go for all the libraries in the code? I have around 10 libraries
And I was just running all libraries one by one to see the errors I’m getting, so for numpy library I got run time error saying the numpy library installed is 0xf but the code is using 0xd version so what about this error. Do I need to change the code or is there a easy solution?
Thanks

1 Like

I checked on github. The problem has been reported and fixed. So I would say you need to update your library. See

1 Like

Hey I’ll look into it.
One thing though, can u share ur mail id I would love if u could collab with me, I have 2 different projects to be done and I’m doing everything on my own. I will update everything to u on email.
Thanks

1 Like

Hey Fractal I successfully ran my code in Thonny IDE but if try to run the same in terminal using command sudo python pa.py I’m getting the following error

Traceback (most recent call last):
  File "/home/pi/Desktop/pa.py", line 1, in <module>
    import shutils
ModuleNotFoundError: No module named 'shutils'

This error is not just for shutils library but for all other libraries too. I think it has something to do with directory of Thonny and terminal. I even tried the code from imutils import * for the imutils library but got the same error for that too. What to do?

1 Like

Change your command to python3 and drop the sudo viz:

python3 pa.py

Check the shutils library is installed by doing a search:

pip3 list

If it is missing install it:

pip3 install shutils

The nice thing about python is there are so many learning aids available and there is even information on this website. When I need to check something my favorite is:

1 Like