eset / ipyida

IPython console integration for IDA Pro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ipyida module not found when using install script

4d5ababe opened this issue · comments

Setup fails when using the install script (one-liner) with "No module named 'ipyida'" during pip install.

IDA v7.4; Python 3.6
Ubuntu 18.04

<pip output>

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 359, in get_provider
    module = sys.modules[moduleOrReq]
KeyError: 'ipyida'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 137, in <module>
  File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1144, in resource_filename
    return get_provider(package_or_requirement).get_resource_filename(
  File "/home/user/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 361, in get_provider
    __import__(moduleOrReq)
ModuleNotFoundError: No module named 'ipyida'

Where did pip install the ipyida package? Do you use a venv or virtualenv inside IDA? What is the result of print(sys.path) in the IDA console?

It's being installed under python2 despite python3 being the default. I think this is because python2/pip are still the default python application in Ubuntu and the install script doesn't distinguish which to use when calling it via subprocess.Popen.

(outside IDA)

pip search ipyida
ipyida (1.4)  - IDA plugin to embed the IPython console inside IDA
  INSTALLED: 1.4 (latest)

pip3 search ipyida
ipyida (1.4)  - IDA plugin to embed the IPython console inside IDA

(IDA console)

Python>import sys
Python>print(sys.path)
['/home/user/idapro/python/3', '/home/user/idapro/python/3/ida_32', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/user/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/home/user/idapro/python', '/home/user/idapro/python', '/usr/lib/python3.6/dist-packages', '/home/user/.idapro/plugins', '/home/user/repos/diaphora', '/home/user/repos/Sark/plugins']

From the install script:

def pip_install(package, extra_args=[]):
    pip_install_cmd = [ sys.executable, "-m", "pip", "install", "--upgrade" ]
    with temp_file_as_stdout():
        p = subprocess.Popen(
            pip_install_cmd + extra_args + [ package ],
            stdin=subprocess.PIPE,
            stdout=sys.stdout,
            stderr=sys.stdout
        )
        ret = p.wait()
    return ret

Ah I think I know where the problem is: https://github.com/eset/ipyida/blob/master/install_from_ida.py#L33

If you have Python 2 (as python) and Python 3 (as python3) installed with the same prefix (i.e. /usr) the install script will install IPyIDA on the Python 2 installation.

I'll fix this by using python3 when running under Python 3.

Can you try again using the script in master?

import urllib.request; exec(urllib.request.urlopen('https://github.com/eset/ipyida/raw/master/install_from_ida.py').read())

Thanks!

Looks like that did the trick. Thanks!

Grrreat! I ff-merged the change to the stable branch. Thanks for reporting and enjoy IPyIDA!