pythonlinuxpython-2.7pipkali-linux

My Kali linux showing 'No module named importlib' 'from importlib import import_module'


Trying to install build dependencies with pip which is installing in /usr/local/lib/python2.7/dist-packages As I try to install proceed gives an error

Collecting git+https://github.com/kti/python-netfilterqueue (from -r requirements.txt (line 1))
  Cloning https://github.com/kti/python-netfilterqueue to /tmp/pip-req-build-VQbxfT
  Running command git clone -q https://github.com/kti/python-netfilterqueue /tmp/pip-req-build-VQbxfT
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python2 /usr/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpNlNAvr                            
       cwd: /tmp/pip-req-build-VQbxfT                                                                                                                                  
  Complete output (4 lines):                                                                                                                                           
  Traceback (most recent call last):                                                                                                                                   
    File "/usr/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py", line 16, in <module>                                                                    
      from importlib import import_module                                                                                                                              
  ImportError: No module named importlib                                                                                                                               
  ----------------------------------------                                                                                                                             
ERROR: Command errored out with exit status 1: /usr/bin/python2 /usr/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpNlNAvr Check the logs for full command output.

so I try to install importlib with pip and I still get the same error. Then I install it directly to /usr/lib/python2.7/dist-packages/pip/_vendor/pep517/ using

pip install importlib --target=/usr/lib/python2.7/dist-packages/pip/_vendor/pep517/

because pip has been installing all packages to /usr/local/lib/python2.7/dist-packages, but I still get the error either way


Solution

  • Assuming you are trying to install python-netfilterqueue.

    You can visit github page and see this

    The current version of NetfilterQueue requires Python 3.6 or later.

    So you can't install this lib for python 2.7

    But you can install 0.9.0 as it also stated that

    The last version with support for Python 2.7 was 0.9.0.

    pip install NetfilterQueue=0.9.0