How to upgrade all Python packages in Kali Linux

Your Kali Linux system is full of obsolete Python packages. You can verify this, in order to display Python 3 packages for which a new version has been released:

pip3 list -o

To display Python 2 packages for which a new version has been released:

pip2 list -o

To upgrade all Python 3 packages at once in Kali Linux, run the following command:

for i in $ (pip3 list -o | awk 'NR> 2 {print $ 1}'); do sudo pip3 install -U $ i; done

To upgrade all Python 2 packages at once in Kali Linux, run the following command:

for i in $(pip2 list -o | awk 'NR > 3 {print $1}'); do sudo pip2 install -U $i; done

pip errors when upgrading Python 3 packages

But more precisely, most packages will be updated – some will not be updated due to various errors and warnings.

An example of a warning when the necessary dependency is missing:

python-debianbts 2.7.3 requires pysimplesoap!=1.16.2, which is not installed.

That is, the python-debianbts package requires pysimplesoap, which is not installed. Solving the problem – just install the missing dependency with a command like this:

sudo pip3 install package_name

for example

sudo pip3 install pysimplesoap

If the problem is with the package for Python 2, then use the appropriate version of pip:

sudo pip2 install package_name

When install all dependencies, run the command to update all packages again to reinstall packages that could not be updated.

An example of another warning in which distutils is mentioned:

Cannot uninstall 'AdvancedHTTPServer'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

The message says that you cannot delete the AdvancedHTTPServer, because it is part of the installed distutils and it is impossible to determine exactly which files belong to it.

You can simply skip the updates of these packages – that is, do nothing.

If you wish to upgrade these packages, use the –ignore-installed option in the command:

sudo pip3 install package_name --ignore-installed

For example, to update AdvancedHTTPServer:

sudo pip3 install AdvancedHTTPServer -U --ignore-installed

If the package is for Python2, then use pip2:

sudo pip2 install package_name --ignore-installed

I also had several other errors, mainly when building packages due to the lack of necessary files. The reason most often is that the necessary dependency is not installed (different headers for compilation). Such errors need to be solved individually – look at which file is missing, look for which package it belongs to, install this package and re-launch the update.

For example:

………………….
    copying cairo/py.typed -> build/lib.linux-x86_64-3.6/cairo
    running build_ext
    'pkg-config' not found.
    Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cyohyrgs/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-y_v2ezqy/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-cyohyrgs/pycairo/

says that pkg-config is not found, install it:

sudo apt install -y pkg-config

Message:

  creating build
  creating build/temp.linux-x86_64-3.6
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DVERSION="1.9.74" -I/usr/include/python3.6m -c cupsmodule.c -o build/temp.linux-x86_64-3.6/cupsmodule.o
  cupsmodule.c:23:10: fatal error: cups/cups.h: Нет такого файла или каталога
   #include <cups/cups.h>
            ^~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pycups

says that the cups/cups.h file is missing, this file is in the libcups2-dev package, install it:

sudo apt install libcups2-dev

Error ‘fatal error: libsmbclient.h: no such file or folder‘:

  copying smbc/__init__.py -> build/lib.linux-x86_64-3.6/smbc
  running build_ext
  building '_smbc' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/smbc
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c smbc/smbcmodule.c -o build/temp.linux-x86_64-3.6/smbc/smbcmodule.o
  In file included from smbc/smbcmodule.c:30:
  smbc/smbcmodule.h:27:10: fatal error: libsmbclient.h: Нет такого файла или каталога
   #include 
            ^~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pysmbc

You need to install the libsmbclient-dev package that contains the required libsmbclient.h file.

sudo apt install libsmbclient-dev

Error Message ‘No package 'cairo' found’:

  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-og2c2qf9/pycairo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-yttz5smu --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/cairo
  copying cairo/__init__.py -> build/lib.linux-x86_64-3.6/cairo
  copying cairo/__init__.pyi -> build/lib.linux-x86_64-3.6/cairo
  copying cairo/py.typed -> build/lib.linux-x86_64-3.6/cairo
  running build_ext
  Package cairo was not found in the pkg-config search path.
  Perhaps you should add the directory containing `cairo.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'cairo' found
  Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1.

To solve the problem, install the packages:

sudo apt install libcairo2-dev libjpeg-dev libgif-dev

Error ‘OSError: mysql_config not found’:

……………………..
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-install-_a5c_n1z/mysqlclient/setup.py", line 16, in 
        metadata, options = get_config()
      File "/tmp/pip-install-_a5c_n1z/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-_a5c_n1z/mysqlclient/setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found

To resolve it:

sudo apt install libmariadbclient-dev

pip errors when upgrading Python 2 packages

Error ‘EnvironmentError: mysql_config not found’:

    Complete output from command python setup.py egg_info:
    sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-build-A1nxJy/mysqlclient/setup.py", line 16, in 
        metadata, options = get_config()
      File "setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-A1nxJy/mysqlclient/

To solve it, install default-libmysqlclient-dev:

sudo apt install default-libmysqlclient-dev

Error ‘fatal error: pcap.h: no such file’:

………………………………...
  building 'pcapy' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-AjKZhf/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pcapdumper.cc -o build/temp.linux-x86_64-2.7/pcapdumper.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  pcapdumper.cc:11:10: fatal error: pcap.h: Нет такого файла или каталога
   #include 
            ^~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pcapy

Its reason is that the pcap.h file was not found, this file is contained in the libpcap-dev package. And to solve this problem you need to install this package.

sudo apt install libpcap-dev

Error ‘Could not run curl-config: [Errno 2] No such file or directory’:

…………………….
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-install-fNcabS/pycurl/setup.py", line 913, in 
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/tmp/pip-install-fNcabS/pycurl/setup.py", line 582, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/tmp/pip-install-fNcabS/pycurl/setup.py", line 99, in __init__
        self.configure()
      File "/tmp/pip-install-fNcabS/pycurl/setup.py", line 227, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-fNcabS/pycurl/

To solve it, install the packages:

sudo apt install libcurl4-openssl-dev libssl-dev

Error ‘possibly undefined macro: AC_PROG_LIBTOOL’:

………………………………..
    configure.ac:47: error: possibly undefined macro: AC_PROG_LIBTOOL
          If this token and others are legitimate, please use m4_pattern_allow.
          See the Autoconf documentation.
    autoreconf: /usr/bin/autoconf failed with exit status: 1
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-install-8JniC2/pylibemu/setup.py", line 244, in 
        libraries    = ["emu"]
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()

To fix it:

sudo apt install libtool

Error ‘fatal error: sqlite3.h: no such file or folder’:

  building 'pysqlite2._sqlite' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-AjKZhf/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DMODULE_NAME="pysqlite2.dbapi2" -IPackage -Isqlite3 -Iwas -Inot -Ifound -Iin -Ithe -Ipkg-config -Isearch -Ipath. -IPerhaps -Iyou -Ishould -Iadd -Ithe -Idirectory -Icontaining -I`sqlite3.pc' -Ito -Ithe -IPKG_CONFIG_PATH -Ienvironment -Ivariable -INo -Ipackage -I'sqlite3' -Ifound -I/usr/include/python2.7 -c src/module.c -o build/temp.linux-x86_64-2.7/src/module.o
  In file included from src/module.c:24:
  src/connection.h:33:10: fatal error: sqlite3.h: Нет такого файла или каталога
   #include "sqlite3.h"
            ^~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------

To fix it, install the package:

sudo apt install libsqlite3-dev

Error ‘No package 'gtk+-3.0' found’:

………………
  checking for GTK+ - version >= 3.0.0... Package gtk+-3.0 was not found in the pkg-config search path.
  Perhaps you should add the directory containing `gtk+-3.0.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'gtk+-3.0' found
  no
  *** Could not run GTK+ test program, checking why...
  *** The test program failed to compile or link. See the file config.log for the
  *** exact error that occured. This usually means GTK+ is incorrectly installed.
  configure: error:
  The development files for GTK+ were not found. For GTK+ 2, please
  ensure that pkg-config is in the path and that gtk+-2.0.pc is
  installed. For GTK+ 1.2 please check that gtk-config is in the path,
  and that the version is 1.2.3 or above. Also check that the
  libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
  --libs' are in the LD_LIBRARY_PATH or equivalent.
  
  Error running configure
  ERROR: failed building wxWidgets
  Traceback (most recent call last):
    File "build.py", line 1321, in cmd_build_wx
      wxbuild.main(wxDir(), build_options)
    File "/tmp/pip-install-_LJgZR/wxPython/buildtools/build_wxwidgets.py", line 375, in main
      "Error running configure")
    File "/tmp/pip-install-_LJgZR/wxPython/buildtools/build_wxwidgets.py", line 85, in exitIfError
      raise builder.BuildError(msg)
  BuildError
  Finished command: build_wx (3.554s)
  Finished command: build (3.554s)
  Command '"/usr/bin/python" -u build.py build' failed with exit code 1.

To fix it, install the following packages:

sudo apt install build-essential libgtk-3-dev

The message ‘You are using pip version …, however version … is available.’

If using pip3 and pip2, messages like this occur:

You are using pip version ..., however version ... is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

That means you need to update the version of pip itself.

To update pip3:

pip3 install --upgrade pip

To update pip2

pip2 install --upgrade pip

Recommended for you:

Leave a Reply

Your email address will not be published.

Looking for a job in IT. Details: https://miloserdov.org/?p=2900