Fixing pip packages installation error – TypeError: parse() got an unexpected keyword argument ‘transport_encoding’

pip packages installation error – TypeError: parse() got an unexpected keyword argument ‘transport_encoding’ is an error which occurs because of compatibility problems with pip.

In the blog post I attempt to explain why this error takes place and how you can solve it, I will also add other solutions that could solve the error if possible.

Exploring the pip packages installation error – TypeError: parse() got an unexpected keyword argument ‘transport_encoding’

This is an error which occurs because of pip compatibility problems.

The error message should look like the message bellow. Make sure you are not dealing with another error.

                                                                       #
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
                                                                       #

Bellow I will present multiple solutions some have worked for me and others have worked for other developers.

Solution 1 : upgrade pip with conda or try upgrading Tensorflow

This is an error which occurs because of pip compatibility problems.

The first solution is to upgrade pip using conda in order to avoid the compatibility problems

                                                                       #
conda install pip
# this is going to upgrade pip to the latest version available
                                                                       #

If you are working with Tensorflow, you can try upgrading Tensorflow since sometimes the error can be caused by compatibility issues between pip and Tensorflow

                                                                       #
python -m pip install --upgrade tensorflow
                                                                       #

Make sure you do not have the GPU version of Tensorflow because that is not going to work.

Solution 2 : Overwrite and install html5lib with anaconda

With anaconda, this problem is caused because of issues with html5lib.

To fix this, you need to navigate to the html5lib folder inside the tensorflow folder inside the envs folder.

                                                                       #
envs\tensorflow\Lib\site-packages\html5lib
                                                                       #

Delete all the files inside that folder and then run the command bellow to install html5lib.

                                                                       #
conda install -c anaconda html5lib
                                                                       #

I hope the fix above fixed your problem, good luck with the scripts to come.

Summing-up : 

The error in this article is one of the most confusing errors in Python, I hope this article has helped you solve the issue or at least pointed you in the right direction. Keep learning guys, keep coding and cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/