3. November 2021

Pipenv on Windows fails AttributeError: ‘NoneType’ object has no attribute ‘version_sort’

There is an issue with Python Pipenv on Windows.

The command to open shell with isolated pipenv you can use command:

python -m pipenv shell

The command might fail on Windows with a strange error like this:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\__main__.py", line 5, in <module>
    cli()
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\cli\command.py", line 429, in shell
    do_shell(
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 2356, in do_shell
    ensure_project(
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 576, in ensure_project
    ensure_virtualenv(
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 388, in ensure_python
    path_to_python = find_a_system_python(python)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 350, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

The problem is caused by pythonfinder.py which is trying to locate a Python.

You can override the pythonfinder.py by explicitly defining the version of the Python.

Determine the version of installed Python:

python --version

Specify the Python version when starting the shell:

python -m pipenv shell --python 3.9.7

The Python environment should start correctly.

29. September 2021

Eclipse error AutoRegisterSchemeHandlersJob AppData\Local\Temp\jna Can’t find dependent libraries

Windows users might experience a very strange errors when starting Eclipse:

An internal error occurred during: "AutoRegisterSchemeHandlersJob".
C:\Users\Vrtižer\AppData\Local\Temp\jna--78847768\jna6432107568184066435.dll: Can't find dependent libraries

It’s possible to continue with the error, but the majority of Eclipse plugins won’t work.

When you look closely at the path you can see there is a special character in the word ‘Vrtižer‘. This special character with a combination of Windows feature ‘Use Unicode UTF-8 for worldwide language support‘ causes the issue.

There are several ways how to workaround the problem:

#1 Change the user environment variable TMP

Open Start, type: environment

Select Edit system environment variables

Click Environment Variables…

Select User variable with name TMP and change it to path without special character, the path must exist.

Click Ok. Start new Eclipse.

Note: the default values is

%USERPROFILE%\AppData\Local\Temp

#2 Remove the user environment variable TMP

If you do not have a special need for user-specific TMP, you can simply delete it. The system will default to System Temp.

Steps are the same as in #1, just instead of Edit, click Detete to remove the variable

Click Ok. Start new Eclipse.

#3 Disable Windows feature ‘Use Unicode UTF-8 for worldwide language support’

Open Start, search for Region settings, click Additional date, time & regional settings, click Change system locale…

Uncheck Use Unicode UTF-8 for worldwide language support, click Ok and restart the computer.

Note: disabling this setting might affect communication between PowerShell and Python scripts in the case of strings with diacritics.

Update: Issue reported to Eclipse.org.

21. September 2021

How to install Podman on Linux Mint 20

Podman binaries for Linux Mint / Ubuntu are hosted by OpenSuse.org.

You need to add the repository to /etc/source.list.d. Common instructions for Ubuntu might not work, because VERSION_ID for Mint is not the same as for Ubuntu.

Instructions for Linux Mint 20.2 from Ubuntu 20.04 repository:

export VERSION_ID="20.04"
sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
sudo wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add -
sudo apt update
sudo apt install -y podman

Example of running container for IoT development:

If you’d like to develop for ESP32 chip connected to /dev/ttyUSB0 using C++ or Rust language, just start the container:

podman run --device /dev/ttyUSB0 -it docker.io/espressif/idf-rust-examples

7. September 2021

How to increase font size of Krita UI on Windows?

Krita on Windows might display UI with a very small font:

You can increase the UI font in Krita by the following configuration. Select from the top menu: SettingsConfigure Krita…

Select General from the left pane, select Window tab, check Use Custom Interface Font, and increase the number to a value like 14. Click Ok to apply changes.

3. September 2021

How to flash ESP32 from WSL

WSL (Windows Subsystems for Linux) is a great way how to build projects based on ESP-IDF. The problem is how to flash the image from WSL Linux to a real chip?

Right now only WSL1 supports mapping of Windows COM ports to Linux /dev/ttyS*.

First of all, make sure that your image is running WSL1 (which is slower than WSL2):

wsl -l -v

In the case of WSL2 image, you can convert it by the following command (let assume the image of Ubuntu):

wsl -t Ubuntu
wsl --set-version Ubuntu 1

Use Windows Device Manager to determine COM ports of your ESP chip. Similar could be achieved by command:

mode

The number of COM.. device will be mapped to the /dev/ttyS.. in Linux.

Start the Linux terminal (e.g. using Windows Terminal). Grant permission so that your user can read write /dev/ttyS* or add your user to dialout group if supported by distribution. Note: on Linux, the device is often mapped to /dev/ttyUSB*, notice the difference on Windows /dev/ttyS*.

chmod a+rw /dev/ttyS*

Build and flash the project. It’s necessary to specify the device name, because autodetection in idf.py is not able to find /dev/ttyS. The second important part is to set the communication speed by “-b” option.

idf.py flash --port /dev/ttyS11 -b 115200
idf.py monitor --port /dev/ttyS11

The last command should launch idf monitor, which you can terminate by CTRL+].

If you’re WSL2 user, you can try alternative approach using idfx tool.