Install PyCharm Community on Linux Mint 21.3

The Linux Mint Software Manager includes the popular Python IDE PyCharm Community, but it’s a Flathub Flatpak and cannot access Python modules installed by Software Manager as System Packages.

For example, after using Software Manager to install Python3 and Python3-tk (System Packages) and PyCharm Community (Flathub Flatpak), try running a simple “Hello, world!” script in PyCharm that opens a Tkinter window:

import tkinter as tk

root = tk.Tk()

w = tk.Label(root, text="Hello, world!")


Instead of a Tkinter window appearing, PyCharm shows the error:

ModuleNotFoundError: No module named 'tkinter'

The error is because the execution environment of the PyCharm Flatpak is separate from the main system, where the tkinter module has been installed.

I’m sure there are other solutions and workarounds, but the simplest solution for me was switching to the official tarball release from JetBrains. PyCharm from the JetBrains release will execute in the main system and have access to all the modules installed there.

Download the release .tar.gz archive for Linux from JetBrains ( After it has downloaded, navigate to your ~/Downloads directory using the GUI file manager (Nemo) and double-click the archive to open it in Archive Manager. Drag the “pycharm-community-yyyy-x.y” folder from Archive Manager to a convenient location where PyCharm will be executed from (I put the folder in my home directory, aka ~ aka /home/username/).

As described in the Install-Linux-tar.txt file in the archive, PyCharm is executed using the bin/ shell script. The first time PyCharm is executed it will create configuration files stored in ~/.config/JetBrains/… (the Install-Linux-tar.txt file has more details).

For convenience, I added the path to to my bash shell path so I can execute PyCharm from a terminal session without having to remember the full path. To do this, I added the following line to the end of ~/.bashrc:

export PATH="$HOME/bin:$HOME/pycharm-community-2023.3.3/bin:$PATH"

I also added a menu entry for PyCharm to the Programming folder in the Linux Mint menu for convenient desktop access.

To do this, right-click on the Linux Mint menu button and select Configure, then Menu, Open the menu editor, Programming folder and finally New Item. Click the Browse button and browse to to create the command line, enter a Name (and if you wish a comment), click the icon box and search for a PyCharm logo, leave the “Launch in terminal” box unchecked, and finally click OK to close the menu editor. For more detailed instructions, search the web for adding a launcher to the Linux Mint menu.

Now PyCharm has no trouble opening a Tkinter window.

The Lost Art of Schematics

Sometime, I don’t know when, schematics stopped being a way to communicate how an electronic circuit works, and instead seem to have become the bare minimum needed for a PCB design.

For example, here is the schematic for the Adafruit Data Logger Shield for the Arduino open-source electronics platform.

The schematic shows how the shield looks physically, and will provide a netlist for PCB design, but it’s a poor tool for conveying the intent and behavior of the design.

It takes some head scratching searching for net names and deciphering overlapping instance names just to glean what’s connected to what. In addition, while a number of jumpers make the shield more general purpose and can be conveniently used with different Arduino boards, there are no explanations!

The designer had the opportunity to make things simple for readers, but didn’t take advantage of it. Instead, we have to read the better half of a 68 page PDF companion document instead of having the information all in one place.

Here is a redrawn version of the same schematic.

Granted it doesn’t have the same expanse of white space, but it provides an order of magnitude of more information. The primary circuit paths can be readily followed visually, component instances are legible, and there are comments to explain the purpose of the jumpers.

Given an opportunity to make things simpler for your audience, why would you instead make it harder?

Accessing the Catnip Electronics RS485 Modbus Moisture Sensor using Python3

Catnip Electronics makes a robust capacitive moisture sensor with a Modbus RS-485 interface which allows the sensor to be over 1000m from the computer accessing the sensor (subject to cable properties and baud rate). This post is essentially an update to Catnip’s Rasberry Pi tutorial using Python 2 using Python3 on my Linux Mint laptop.

To connect to the moisture sensor, I will use the Taobao USB to RS-485 adapter sold by Catnip Electronics.

Start by installing python3-pip.

dale@firefly:~$ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  build-essential g++ g++-9 libpython3-dev libpython3.8-dev libstdc++-9-dev python3-dev python3-setuptools
  python3-wheel python3.8-dev
Suggested packages:
  g++-multilib g++-9-multilib gcc-9-doc libstdc++-9-doc python-setuptools-doc
The following NEW packages will be installed:
  build-essential g++ g++-9 libpython3-dev libpython3.8-dev libstdc++-9-dev python3-dev python3-pip
  python3-setuptools python3-wheel python3.8-dev
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.2 MB of archives.
After this operation, 70.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Next, install the chip_modbus library (“Chirp” was the original I2C moisture sensor from Catnip Electronics, which was upgraded to become the Modbus sensor).

dale@firefly:~$ sudo pip install chirp_modbus
[sudo] password for dale:          
Collecting chirp_modbus
  Downloading chirp_modbus-1.0.2.tar.gz (2.5 kB)
Collecting minimalmodbus>=1.0.2
  Downloading minimalmodbus-2.0.1-py3-none-any.whl (33 kB)
Collecting pyserial>=3.0
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     |████████████████████████████████| 90 kB 1.9 MB/s 
Building wheels for collected packages: chirp-modbus
  Building wheel for chirp-modbus ( ... done
  Created wheel for chirp-modbus: filename=chirp_modbus-1.0.2-py3-none-any.whl size=2720 sha256=4a869530f8de35b421d5556e1677ca1d760bb48f7107510d6e8946b5130e7128
  Stored in directory: /root/.cache/pip/wheels/b8/e4/54/e09426372abf3522455f8c54ec6b7988e9f1c5e7a5a2f9b61d
Successfully built chirp-modbus
Installing collected packages: pyserial, minimalmodbus, chirp-modbus
Successfully installed chirp-modbus-1.0.2 minimalmodbus-2.0.1 pyserial-3.5

Now use the Python shell to access the sensor (on my laptop, the USB to RS-485 adapter is assigned port /dev/ttyUSB0).

dale@firefly:~$ python3
Python 3.8.10 (default, Mar 15 2022, 12:22:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import chirp_modbus
>>> sensor = chirp_modbus.SoilMoistureSensor(address=1, serialport='/dev/ttyUSB0')
>>> sensor.getMoisture()
>>> sensor.getTemperature()

The chip_modbus library includes a number of other functions, view the source to see all capabilities.