New GitHub issue #92282 from SBS-jtemplin:<br>

<hr>

<pre>
**Bug report**

Importing numpy fails when compiling CPython to a DLL in two ways

When compiling to a UWP DLL and and importing numpy in python using PyObject_CallObject I get the following error:
```
Traceback (most recent call last):
File "C:\path-to-build\tests.py", line 37, in import_numpy_exception
import numpy
File "C:\path-to-build\python310.zip\site-packages\numpy\__init__.py", line 128, in <module>
from numpy.__config__ import show as show_config
File "C:\path-to-build\python310.zip\site-packages\numpy\__config__.py", line 13, in <module>
os.add_dll_directory(extra_dll_dir)
File "os.py", line 1117, in add_dll_directory
OSError: [WinError 87] The parameter is incorrect: 'C:\\path-to-build\\python310.zip\\site-packages\\numpy\\.libs'
```

This happens in debug and release builds.

When compiling to a standard DLL I can call os.add_dll_directory using PyRun_SimpleString, but still can't import numpy. I've tried PyImport_import("numpy"), PyImport_ImportModule("numpy"), PyImport_AddModule("numpy") and they all return nullptr. I've also tried importing numpy in python using PyObject_CallObject and it fails with the following error:
`Assertion failed: !PyErr_Occurred(), file D:\a\1\s\Objects\typeobject.c, line 3264`

All of the above functions are able to import django successfully, so I don't believe it is a simple path issue. They also import numpy successfully when running in a console app.

So why does importing numpy fail in a DLL? 

**Your environment**

- CPython versions tested on:
  3.9.12 and 3.10.2
- Operating system and architecture:
  Windows 10.0.19044 Build 19044


</pre>

<hr>

<a href="https://github.com/python/cpython/issues/92282">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>