Python Virtual Environments - Resource to understand

I am guilty of ignoring software standards and conventions in my robotics projects.

The Python “gods” have noticed and are chasing me. Bookworm releases of both PiOS and Ubuntu are not so gently demanding I learn and get comfortable with coding all Python in virtual environments.

Good resource to get familiar with this convention and growing standard is in the official Raspberry Pi documentation

Since the GoPiGo3 software is usually installed at the system level in official ModRobotics OS (and all the Ubuntu install scripts I have built) we need to be sure when creating project virtual environments to include the GoPiGo3 eggs:

python -m venv --system-site-packages gpg3env

I may try creating only one of these, put the activate in my .bashrc, and simply live in the virtual environment, never returning to the reality of Python convention.

I still need to figure out if an apt install at the system level, after the virtual environment was created with sys pkgs, will it also update the virtual environment’s system packages. And will issuing an apt install in a virtual environment install only to that virtual environment or also at the system level?

3 Likes

You’re reminding me of the Abbott and Costello routine Who’s on first?

:wink:

2 Likes

Seems like a kind of kludge and it makes Linux looks like a house of cards! I am also wondering how hard it would be to switch from python to C++ for coding ROS nodes… Has anyone tried this for the GoPiGo python modules?

3 Likes

Not that I am aware of - I searched GitHub for ROS on GoPiGo3 quite extensively a couple years ago.

I recently wrote a C++ GoPiGo3 program to reacquaint myself with C++ and prove the C++ API to the GoPiGo3 exists and works, but I didn’t test sensors. The GoPiGo3 C++ API did not appear as rich as the Python API, but the basic GoPiGo3 ROS node really only needs motors and encoders which are there in the C++ GoPiGo3 API.

I’ve had my Python ROS2 GoPiGo3 node require changes when moving from one version of ROS 2 to the next. I wonder if the C++ ROS node would have been more stable from version to version.

3 Likes

Having studied various operating systems, (and how to break them doing SQA), I can assure you that Linux is no more a “house of cards” than other OS’s, especially Windows.

The big difference is that Linux is an Open Source/FOSS system where all the dirty laundry is hung out for all to see - whereas Windows, (and other closed systems), don’t expose the kludgy construction, hiding it behind other kludges, which are hidden behind other kludges in turn.

E.g. IMHO “Windows Update” is a classic recursive [kludge] that demonstrates how much of a [complete balls-up] Windows is.

1 Like

Sorry but I’ll have to disagree there. I have had very little trouble with Windows from Win 7 on but my experiences with Linux flavors has been uniformly bad. I just think an OS that relies on a scripting language for important functionality is inherently fragile and the fact that pip can damage the OS, causing the need to create virtual environments to protect the OS is evidence of that fragility, hence Linux reminds me of a house of cards. :house: :fallen_leaf: :chart_with_downwards_trend: :arrow_right: :frowning_face:

2 Likes