Jinmo / idapkg

Packages for IDA Pro (written in python but supports all)
MIT License
131 stars 16 forks source link

[Bug] Several errors occur while installing virtualenv #18

Closed bruce30262 closed 10 months ago

bruce30262 commented 4 years ago

ENV

OS: Windows 10 Python: 3.8.5 IDA version: 7.5 IDAPython: v7.4.0
idapkg : 0.1.4

Details

During the installation, the install command shows the following error message:

idapkg version 0.1.4
Will install virtualenv at 'C:\\Users\\bruce30262\\idapkg\\python' since pip module is not found...
Downloading virtualenv from 'https://files.pythonhosted.org/packages/57/6e/a13442adf18bada682f88f55638cd43cc7a39c3e00fdcf898ca4ceaeb682/virtualenv-20.0.21-py2.py3-none-any.whl' ...
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 90, in prepare_virtualenv
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\bruce30262\AppData\Local\Programs\Python\Python38\Lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\bruce30262\AppData\Local\Programs\Python\Python38\Lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "<string>", line 2, in install
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\main.py", line 87, in init_environment
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 110, in prepare_virtualenv
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 108, in handler
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 108, in <listcomp>
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 106, in <lambda>
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmpn4i1x85y.zip\idapkg-0.1.4\pkg\virtualenv_utils.py", line 67, in _install_virtualenv
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmp68526rtt.zip\virtualenv\__init__.py", line 3, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmp68526rtt.zip\virtualenv\run\__init__.py", line 5, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\BRUCE3~1\AppData\Local\Temp\tmp68526rtt.zip\virtualenv\run\app_data.py", line 6, in <module>
ModuleNotFoundError: No module named 'appdirs'

The ImportError message will be shown while importing the following modules:

All error can be resolved by using pip3 install <module>

Side note: idapkg cannot find pip on my machine because this line of code

After that, the install script will emit another error:

Creating environment using virtualenv...
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 90, in prepare_virtualenv
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\bruce30262\AppData\Local\Programs\Python\Python38\Lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\bruce30262\AppData\Local\Programs\Python\Python38\Lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "<string>", line 2, in install
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\main.py", line 87, in init_environment
    prepare_virtualenv(wait=True)
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 110, in prepare_virtualenv
    __work(handler) if not wait else handler()
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 108, in handler
    def handler(): return ([task()
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 108, in <listcomp>
    def handler(): return ([task()
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 106, in <lambda>
    tasks.insert(0, lambda: _install_virtualenv(path))
  File "C:\Users\bruce30262\idapkg\packages\idapkg\pkg\virtualenv_utils.py", line 71, in _install_virtualenv
    virtualenv.create_environment(path, site_packages=True)
AttributeError: module 'virtualenv' has no attribute 'create_environment'

The error seems to have something to do with this issue

Jinmo commented 4 years ago

Thanks for the report! In fact I didn't check when upgrading virtualenv; now it has several dependencies?!.. :thinking: Maybe I should stick with old version and upgrade pip after installing them. I'll explore available options for this.

Jinmo commented 4 years ago

In addition, could you elaborate more on this issue?

Side note: idapkg cannot find pip on my machine because this line of code

I've added it to make IDA use pip inside virtualenv, but it might not work as I intended.

bruce30262 commented 4 years ago

In addition, could you elaborate more on this issue?

So in my VM I had my python3.8 installed:

>where python
C:\Users\<omitted>\AppData\Local\Programs\Python\Python38\python.exe

>py -m pip --version
pip 20.1.1 from C:\Users\<omitted>\AppData\Local\Programs\Python\Python38\lib\site-packages\pip (python 3.8)

I've also confirmed that in IDA's python shell, when I enter import pip, it import the module without any problem.

I modified virtualenv_utils.py to print out os.path.abspath(pip.__file__) and abspath, here's the result:

os.path.abspath_pip: C:\Users\<omitted>\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\__init__.py
abs_path: C:\Users\<omitted>\idapkg\python
Jinmo commented 4 years ago

Temporary reverted virtualenv version in c7a7de5, since the fix will take non-small time I guess..

bruce30262 commented 10 months ago

Closing issue due to discontinuation of the project