binwalk: Pip install causes: ModuleNotFoundError: No module named 'binwalk.core.version'

Sorry if this had been discussed before, But I was not able to find any mention of it.

I just installed binwalk on a new computer using the command python3 -m pip install git+https://github.com/ReFirmLabs/binwalk

I then tried to run the binwalk script (I tried using just binwalk and also tried python3 -m binwalk but got similar results) but got the following output:

$ binwalk
Traceback (most recent call last):
  File "/usr/bin/binwalk", line 25, in <module>
    import binwalk
  File "/usr/lib/python3.6/site-packages/binwalk/__init__.py", line 4, in <module>
    from binwalk.core.version import __version__ # This file is auto-generated by setup.py and ignored by .gitignore
ModuleNotFoundError: No module named 'binwalk.core.version'

$ python3 -m binwalk
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3.6/site-packages/binwalk/__init__.py", line 4, in <module>
    from binwalk.core.version import __version__ # This file is auto-generated by setup.py and ignored by .gitignore
ModuleNotFoundError: No module named 'binwalk.core.version'

A quick ls revealed this:

$ ls /usr/lib/python3.6/site-packages/binwalk/core
    __init__.py
    __pycache__
    common.py
    compat.py
    display.py
    exceptions.py
    idb.py
    magic.py
    module.py
    plugin.py
    settings.py
    statuserver.py

The reason for this is because the arguments passed to setup.py look like this from pip: ['-c', 'bdist_wheel', '-d', '/tmp/pip-wheel-78sn9x5f', '--python-tag', 'cp36'] and version.py is only created if ‘install’ or ‘build’ is in the arguments

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 12
  • Comments: 28

Most upvoted comments

2 years later and still not working with pip 😕

Hasn’t installed properly on a couple of systems for me using pip but the following always works.

git clone https://github.com/ReFirmLabs/binwalk.git
cd binwalk
sudo python setup.py install

@airplacepapercup

I’m afraid you don’t seem to get the title of the issue. The issue is not that I can’t install it, but that the module does not support pip installing.

I then even went on to give specifics on WHY the module does not support pip installing.

Pip installations make it very easy to add or remove modules, and having a module that doesn’t support it (and doesn’t support it because the installation is supposed to generate the version file) is rather uncommon in well known modules.

Also, please notice that I even went and responded with how I fixed it, indicating that a temporary solution to support pip installation has now been provided, something that your method unfortunately does not address.

https://github.com/ReFirmLabs/binwalk/wiki/Quick-Start-Guide

Try installing binwalk similar to this post. I had the same issue and it worked for me.

I personally fixed my installation by using

$ echo -e '# This file has been auto-generated by setup.py\n__version__ = "2.1.2"\n' > /usr/lib/python3.6/site-packages/binwalk/core/version.py

@TruncatedDinoSour lol and 2 minutes to have a dig about it 😃 What does ls -l $(which python) give you after that? If you add it to the end of path, it does not run python from the $HOME\.venv/bin folder first, which is the whole point of it.

sudo apt install python3-venv
export PATH="$HOME/.venv/bin:$PATH"
python3 -m venv ~/.venv
source ~/.venv/bin/activate
pip install binwalk

What does ls -l $(which python) give you now?

RTFM to put it bluntly then https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments Windows instructions available too!

I was about to say alternatively run ~/.venv/bin/activate lol