Error detected while processing function jedi#init_python[11]..26_display_exception:

While using Vim in a Python virtual environment created using the venv module, this error pops up when opening a Python script:

Error detected while processing function jedi#init_python[11]..26_display_exception:
line 19:
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: ModuleNotFoundError: No module named ‘jedi’ (in function jedi#init_python[4]..26_init_python[27]..jedi#setup_python_imports, li
ne 27). See :messages and/or :JediDebugInfo for more information.

Let’s gather some information about the working environment:

Vim version:

:vers

VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 19 2020 13:12:18)
Included patches: 1-875, 878, 884, 948, 1046, 1365-1368, 1382, 1401

OS information:

cat /etc/os-release
NAME="Ubuntu"
VERSION="19.10 (Eoan Ermine)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 19.10"
VERSION_ID="19.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=eoan
UBUNTU_CODENAME=eoan

Current status of the jedi-vim plugin installation:

dpkg -l |grep vim-python-jedi

Package: vim-python-jedi
Version: 0.14.1-1
Priority: optional
Section: universe/python
Source: python-jedi
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Piotr O┼╝arowski
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 117 kB
Depends: python3-jedi, vim-nox | vim-python
Recommends: vim-addon-manager
Homepage: https://github.com/davidhalter/jedi
Download-Size: 24.0 kB
APT-Manual-Installed: yes
APT-Sources: http://ca.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
Description: autocompletion tool for Python - VIM addon files
Jedi is an autocompletion tool for Python. It works. With and without
syntax errors. Sometimes it sucks, but that's normal in dynamic languages.
But it sucks less than other tools. It understands almost all of the basic
Python syntax elements including many builtins.
.
`vim-addons install python-jedi` will create all needed symlinks in
~/.vim/

Vim plugins using the OS package installer (for Debian/Ubuntu based distros) are handled by the vim-addons utility.

To list all the installed Vim plugins:

vim-addons list


editexisting
espeak
justify
matchit
python-jedi

The version provided by Ubuntu for jedi-vim is older than the latest one publicly available. For more details about the releases: jedi-vim releases

Since version 8, Vim has now a native plugins management.

For more details:


:h packages
:h package-create

To install the vanilla version of jedi-vim and have it available at Vim startup:


unzip -d jedi-vim ~/Downloads/jedi-vim-0.10.0.zip
mkdir -p ~/.vim/pack/vendor/start/jedi-vim
cp -rf jedi/vim/* ~/.vim/pack/vendor/start/jedi-vim/

~./vim/pack/vendor/start is the destination folder for any packages that contain plugins for Vim and automatically enabled at startup.

The plugin is now available and ready to be used in Vim.

If Vim is used in a Python virtual environment, the following error pops up:

jedi-vim: Error when loading the jedi python module (module ‘jedi’ has no attribute ‘__version__’). Please ensure that Jedi is installed correctly (see Installation in the README.

Furthermore, the Python code autocompletion feature provided by jedi-vim is not available in Vim.

2 options are available to fix this issue:

Either install the Python module jedi within the virtual environment using pip

Or re-create the virtual environment and enable access to the system site-packages dir (https://docs.python.org/3.7/library/venv.html) as follows:

python3 -m venv --system-site-packages my_new_env

Enable this new virtual environment:

cd $HOME/my_new_env

source bin/activate

python -c 'import jedi'

If there is anything wrong with loading this module:

Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘jedi’

This module will be picked up from the version installed using the OS package manager. For Ubuntu, jedi is provided by the python3-jedi package.

Python auto-completion in Vim with python-jedi on Ubuntu 19.04

python-jedi is a plugin available for Vim that features auto-completion for the Python programming language.
It is available as an Ubuntu package :


apt install vim-python-jedi

To enable it as a user :


vim-addons install python-jedi

or


vam install python-jedi

To start using it in Vim, the keyboard shortcut CTRL+Space is a good start for auto-completing.

Further readings :

jedi autocompletion library for VIM

VIM for development on Stackabuse

pandas.errors.ParserError: Error could possibly be due to quotes being ignored when a multi-char delimiter is used.

From the Python regular expressions HOWTO, here is the list of metacharacters :

. ^ $ * + ? { } [ ] \ | ( )

In the Pandas library, while reading a csv with an uncommon delimiter such as |~|, you can have this error :

pandas.errors.ParserError: Error could possibly be due to quotes being ignored when a multi-char delimiter is used.

From the Pandas documentation, any delimiter longer than 1 character is considered as regular expressions. The multi-char delimiter is set up in the sep parameter.

For this example |~|, | is a metacharacter and to use it as a simple character, \ must be used. \ being itself a metacharacter, double quotes must be used : "\\|~\\|"

Pandas library version used : 0.24.2

Pandas User Guide : https://pandas.pydata.org/pandas-docs/stable/user_guide/index.html

Please set the ICU_VERSION environment variable to the version of ICU you have installed.

This runtime error pop up while installing Python module dataset with pip in a virtual environment on a Linux VM running Ubuntu 18.04.1 LTS.

The dataset Python module requires several dependencies, pyicu being one of them.

As mentioned on the PyICU Github project webpage, this is a Python extension wrapping the ICU C++ libraries.

Using the apt-file tool, icu-config is provided by the libicu-dev Ubuntu package.

After installing it with the package manager, dataset Python module is now properly installed.

glib.error : g-io-error-quark : cannot autolaunch D-Bus without X11 $DISPLAY

To send simple notifications on your Linux desktop, pydbus can be used for such task.

PyDBus details

Pretty straightforward if you run it in a script from your shell.

If you need to automate it using cron, then 2 environment variables must be set :

import os
os.environ['DBUS_SESSION_BUS_ADDRESS'] = 'unix:path=/run/user/USERID/bus'
os.environ['DISPLAY'] = ':0'

You can tweak the example from the official Github repos for this project :

Send a desktop notification

From

from pydbus import SessionBus

bus = SessionBus()
notifications = bus.get('.Notifications')

notifications.Notify('test', 0, 'dialog-information', "Hello World!", "pydbus works :)", [], {}, 5000)

To

Send a desktop notification from Cron

from pydbus import SessionBus
import os
os.environ['DBUS_SESSION_BUS_ADDRESS'] = 'unix:path=/run/user/USERID/bus'
os.environ['DISPLAY'] = ':0'

bus = SessionBus()
notifications = bus.get('.Notifications')

notifications.Notify('test', 0, 'dialog-information', "Hello World!", "pydbus works :)", [], {}, 5000)

Tested successfully for Python 3

NB : You can retrieve your user id using the id command.