Can't install python packages with pip

Hi,

I am a python programmer and sometimes need install global packages (not always venvs), well about 1 month i have a permanently error when i try to install any package, by example:

sudo pip install pgcli

Collecting pgcli
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/usr/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 291, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3.6/site-packages/pip/_internal/resolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "/usr/lib/python3.6/site-packages/pip/_internal/resolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3.6/site-packages/pip/_internal/resolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 245, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "/usr/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 307, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 484, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 442, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 587, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 705, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 833, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 753, in init
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

The same with any package. There is no problem with pacman -S python-requests or with pip2 install pgcli and i have try reinstall the pip package.

Any ideas?

Taking as reference https://stackoverflow.com/questions/46499808/pip-throws-typeerror-parse-got-an-unexpected-keyword-argument-transport-enco

Solution:
sudo pip uninstall tensorflow (just in case, use only inside venv)
sudo pip uninstall html5lib
sudo pacman -S python-html5lib
sudo pip install html5lib
sudo pip install pgcli

Take a careful read :slight_smile:

2 Likes

Why does everyone who uses Python use sudo pip install and then not be able to fix it? :sob:

5 Likes

It appears you've found a Universal Truth. :sad:

Because they are all startup programmers and not sysadmins ? :japanese_ogre:
(but seriously ... this is like a 3 times a week topic..)

Sounds like another candidate for the big flashing red WARNING before it can be installed.

I'd almost be in favor of a warning, kickoff, point to docs, etc the first time sudo pip was used.
But on the whole I'm still conflicted about the idea of the system protecting users from themselves.

1 Like

Where I see the major issue is that legitimate technical help requests can go and unanswered because they end up getting buried by a bunch of easily avoidable (but numerous) help requests. That becomes a real issue as Manjaro gets more popular and the volume of help requests increases daily.

Perfect example I just spotted a wifi help post from 15 hrs ago that I missed. I guess Jonathon re-categorized it, and it got bumped up. I totally missed it because of the volume of posts that is happening every day.

On Manjaro - and Arch + derivatives never install systemwide python packages using pip with sudo.

First check with Add/Remove Software app if your python package is available.

Packages starts with python- for Python 3 packages and python2- for Python 2 packages.

If you need a specific package for development purpose - always use the virtual environment wrapper.

sudo pacman -Syu python-virtualenvwrapper

Source the file /usr/bin/virtualenvwrapper.sh in your .bashrc or .zshrc and create a virtual env

mkvirtualenv your-dev

Inside the virtualenv you can install packages with pip without messing with the systems python packages.

Some times I use a search for unanswered posts to see if I can provide insight.

1 Like

A post was split to a new topic: How to use pip with virtualenv

Forum kindly sponsored by