Andrew Fletcher published: 2 October 2023 (updated) 3 October 2023 1 minute read
Python3
Error
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/{project}/.local/lib/python3.8/site-packages/markupsafe/__init__.py)
Update all PIP packages
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
However, this failed due to
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
To resolve the X509_V_FLAG_CB_ISSUER_CHECK error, run
sudo pip3 install pyOpenSSL --upgrade
sudo pip3 install cryptography --upgrade
Back on track
The "ImportError: cannot import name 'soft_unicode' from 'markupsafe'" occurs as a result of soft_unicode method has been deprecated in markupsafe version 2.1.0. Now to check the current version that's in use of key packages
Package Version
----------------------- --------------------
Jinja2 2.10.1
MarkupSafe 2.1.3
pip 20.0.2
Checking jinja2
The minimum versions of this package are expected by Jinja2:
# for pinned (obsolete) Jinja2: `MarkupSafe` has been automatically downgraded by `pip` to `2.0.1`
MarkupSafe==2.0.1
- Jinja2==2.11.3 [requires: MarkupSafe>=0.23]
# whereas unpinned:
# for unpinned (latest) Jinja2: using latest version of `MarkupSafe`
MarkupSafe==2.1.1
- Jinja2==3.1.2 [requires: MarkupSafe>=2.0]
Downgrading MarkupSafe
Downgrading markupsafe module to 2.0.1 version
pip install markupsafe==2.0.1
pip3 install markupsafe==2.0.1
Response
Collecting markupsafe==2.0.1
Downloading MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
Installing collected packages: markupsafe
Attempting uninstall: markupsafe
Found existing installation: MarkupSafe 2.1.3
Uninstalling MarkupSafe-2.1.3:
Successfully uninstalled MarkupSafe-2.1.3
Successfully installed markupsafe-2.0.1
Confirming that the current version of markupsafe has been downgraded
Package Version
----------------------- --------------------
Jinja2 2.10.1
MarkupSafe 2.0.1
pip 20.0.2
Related articles
Andrew Fletcher
•
25 Apr 2024
Python issue when installing libraries - error: externally-managed-environment
When attempting to install python libraries on my OSXpip3 install pandas, numpy, matplotlibI'm seeing the following responseserror: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the...
Andrew Fletcher
•
29 Feb 2024
Python - OSError: [Errno 24] Too many open files
The "Too many open files" error in Python typically occurs when your program has opened more file descriptors than the operating system allows. This error is often seen in situations where files are not being properly closed after use, leading to the exhaustion of available file...
Andrew Fletcher
•
17 Feb 2024
How to update installed Python packages
You can use the pip list --outdated command to view a list of installed Python packages that have newer versions available. This command will show you which packages are outdated and can be updated to the latest versions.Here's how you can use itpip list --outdatedThis command will display a list of...