pip throws "TypeError: deprecated() " error
Asked Answered
L

9

10

I am trying to install few packages and started getting an error. Then used multiple commands in ubuntu to update few things but errors are similar

pip install -U pip setuptools
or
python3 -m pip install --upgrade pip
or
sudo -H pip3 install --upgrade pip

Following is the error sample

user@machine:~$ pip install cryptography

Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 65, in <module>
    vendored("cachecontrol")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
.
.
.
.
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
  File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import SSL, crypto
  File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/SSL.py", line 19, in <module>
    from OpenSSL.crypto import (
  File "/home/dhome/.local/lib/python3.8/site-packages/OpenSSL/crypto.py", line 3224, in <module>
    utils.deprecated(
TypeError: deprecated() got an unexpected keyword argument 'name'

I have updated the system with apt-get install libffi-dev python-dev python3-dev and apt-get install build-essential libssl-dev already as suggested in here

Loewi answered 12/10, 2022 at 11:46 Comment(1)
That looks like an issue with cryptography/pyopenssl packages.Ganymede
L
33

Something got broken down in OpenSSL and no command was working with pip afterwards. I was even unable uninstall pip.

I removed installation files manually (most likely not a recommended approach) with

sudo rm -rf /usr/local/lib/python3.8/dist-packages/OpenSSL
sudo rm -rf /usr/local/lib/python3.8/dist-packages/pyOpenSSL-22.1.0.dist-info/

and reinstalled using pip3 install pyOpenSSL==22.0.0. The other version was having some issue as described here.

Loewi answered 12/10, 2022 at 18:33 Comment(1)
I removed OpenSSL from /home/<username>/.local/lib/python3.8/site-packages folder and got it solved.Visible
M
4

Reinstalling pyOpenSSL should work.

This pip install pyOpenSSL==22.0.0 works for me.

Mosier answered 24/7, 2023 at 6:22 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Jannery
This worked for me too! Ran into this issue on 24.0.0 and going to 22.0.0 solved it for meMadalena
F
1

For me even uninstall of pyOpenSSL was encountering same error TypeError: deprecated() got an unexpected keyword argument 'name'

so first I upgraded pip to 23.0 ,uninstall PyOpenSSL,manually deleted openSSL folder from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages then installed PyOpenSSL 20.0.0, finally issue resolved.

Fraze answered 3/2, 2023 at 12:51 Comment(0)
J
1

Upgrading pyOpenSSL worked for me!

pip install pyOpenSSL --upgrade
Jolyn answered 30/3, 2023 at 11:19 Comment(0)
J
1

The accepted answer did not work for me (Python 3.8.10).

I solved the issue by creating a fresh virtual environment and upgrading pip (from 20.x to latest version as of now 23.1):

pip install --upgrade pip

Only after that I installed the other dependencies.

Journalistic answered 17/4, 2023 at 14:49 Comment(0)
P
0

Addition to dhariya's solution, try removing OpenSSL from .local as well

sudo rm -rf $home/.local/lib/python3.8/site-packages/OpenSSL/

Pavia answered 21/7, 2023 at 7:12 Comment(0)
P
0

Despite attempting various commands, I couldn't resolve the problem. However, after restarting my device, pip started functioning correctly.

Palatine answered 15/9, 2023 at 16:21 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Jannery
M
0
  1. I switched the env to base,

conda activate base

  1. upgrade pyOpenSSL,

pip install --upgrade pyOpenSSL

It worked for me.

Melpomene answered 26/8 at 2:42 Comment(0)
K
-1

I know this isn't a good fix but you can just add sudo before the rest of the command. It bypasses the error.

without sudo

with sudo

Kirtle answered 8/3, 2023 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.