AttributeError: module 'pkg_resources' has no attribute 'safe_name' oauthlib install
Found the solution. I had to upgrade setuptools, so:
$ sudo pip3 install --upgrade setuptools
I ran into the same error while running pip inside a virtualenv environment, however setuptools were already up-to-date in my case.
What fixed it for me
# exit the virtualenv
deactivate
# re-initialize your virtual environment (your command may differ)
virtualenv --python=python3.7 env
# activate the virtualenv again
source env/bin/activate
# re-install your dependencies
pip install -r requirements.txt
Root cause
The root cause in my case was that I had accidentally deleted the pkg-resources
pip package that virtualenv creates in ubuntu. Since pip install pkg-resouces
fails (pkg-resources
is not a real pypi package), reinitializing virtualenv is the only way to get that package back.