# Import idapro in the GUI exits IDA without saving

**URL:** <https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792>\
**Category:** Bugs\
**Created:** [September 6, 2026, 2:43am UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792 "2026-09-06T02:43:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harding](https://sea2.discourse-cdn.com/flex002/user_avatar/community.hex-rays.com/harding/32/37_2.png) [@Harding](https://community.hex-rays.com/u/Harding)\
**Post date:** [September 6, 2026, 2:43am UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792/1 "2026-09-06T02:43:00Z")

</div>

I was going to `import ida_ida` but by mistake wrote `import idapro` and then IDA shutdown without saving my database.

This was from inside IDA Pro 9.4 with GUI up on a Windows 10.

---

<div class="post-metadata">

**Author:** ![igor](https://sea2.discourse-cdn.com/flex002/user_avatar/community.hex-rays.com/igor/32/35_2.png) [@igor](https://community.hex-rays.com/u/igor)\
**Post date:** [September 7, 2026, 12:45pm UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792/2 "2026-09-07T12:45:44Z")

</div>

What version is your `idapro` module and how did you install it? Normally, it should have this check at the start of [` __init__.py`](https://github.com/HexRaysSA/idapro/blob/main/idapro/ __init__.py):

```auto
_main = sys.modules.get(" __main__")
if _main is not None and getattr(_main, "IDAPYTHON_VERSION", None) is not None:
    raise ImportError("The IDA library can only be run in a separate process and cannot be loaded within IDA itself.")

```

---

<div class="post-metadata">

**Author:** ![Harding](https://sea2.discourse-cdn.com/flex002/user_avatar/community.hex-rays.com/harding/32/37_2.png) [@Harding](https://community.hex-rays.com/u/Harding)\
**Post date:** [September 10, 2026, 10:24pm UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792/3 "2026-09-10T22:24:11Z")

</div>

I’m on 0.0.10 which is the latest pip gave me. What happens when you run it in the GUI?

---

<div class="post-metadata">

**Author:** ![igor](https://sea2.discourse-cdn.com/flex002/user_avatar/community.hex-rays.com/igor/32/35_2.png) [@igor](https://community.hex-rays.com/u/igor)\
**Post date:** [September 11, 2026, 11:00pm UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792/4 "2026-09-11T23:00:50Z")

</div>

Here’s what happens normally:

```auto
Python>import idapro
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python311\Lib\site-packages\idapro\ __init__.py", line 16, in <module>
    raise ImportError("The IDA library can only be run in a separate process and cannot be loaded within IDA itself.")
ImportError: The IDA library can only be run in a separate process and cannot be loaded within IDA itself.

```

You can use importlib to check what specific lbrary it’s trying to import:

```auto
Python>import importlib
Python>importlib.util.find_spec("idapro").origin
'C:\\Python311\\Lib\\site-packages\\idapro\\ __init__.py'

```

---

<div class="post-metadata">

**Author:** ![Harding](https://sea2.discourse-cdn.com/flex002/user_avatar/community.hex-rays.com/harding/32/37_2.png) [@Harding](https://community.hex-rays.com/u/Harding)\
**Post date:** [September 15, 2026, 8:53am UTC](https://community.hex-rays.com/t/import-idapro-in-the-gui-exits-ida-without-saving/792/5 "2026-09-15T08:53:55Z")

</div>

I found the problem. It was that IKernel set `sys.modules[" __main__"]` but I added the `IDAPYTHON_VERSION` so it’s all good now 🙂
