Error importing C-extensions for Numpy on Win10 Conda Env

122 views
Skip to first unread message

Kai Brown

unread,
Jan 13, 2021, 5:56:59 AM1/13/21
to modwsgi
Hi there,

I posted a question already but it may have been lost in moderation as I cannot view it in any tab or view on the website...
  • I have setup an apache installation through WAMP on windows and connected it to a virtual environment on anaconda python 3.8 called 'MMDBpy', installing Mod_WSGI into the venv and using module-config to configure Apache. 
  • I am trying to host a flask app on localhost on a local network with a self-signed ssl certificate for completeness (Limited users and we are aware of possible certificate duplication). My app's code runs correctly in debug mode, connecting to the WAMP MySQL server for data to display.
---Python Installation in use:
sys.version = '3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]' sys.prefix = 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy'  

---Python module search path:
sys.path = ['C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\python38.zip', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\DLLs', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib', 'C:\\wamp64\\bin\\apache\\apache2.4.46\\bin', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib\\site-packages', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib\\site-packages\\win32', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib\\site-packages\\Pythonwin']  

---Embedded or Daemon Mode Check:
mod_wsgi.process_group = ''  

---Python Sub-interpreter Check:
mod_wsgi.application_group = ''  

---Multithreading Check:
wsgi.multithread = True  
  • I ran into a problem when I tried to use MMDBpy.wsgi to import my Python Dash App from my scripts. I saved the scripts into the install location of my venv because it appears on the python module path and the .wsgi file could then detect and import it.
  • This successfully begins running my dash app but fails when importing pandas - the c-extensions of numpy throw an error:
  • I reinstalled python and repeated the entire mod_WSGI configuration problem but it didnt solve it  - conda shows numpy and pandas are both up to date. The website given for NumPy in the error logs blames the installation or a problem with activating the environment... That's as far as I've got.
  • Any help with this is much appreciated. :)
---Error Log - Log level INFO:
[Wed Jan 13 11:22:48.082868 2021] [ssl:info] [pid 6032:tid 1292] [client ::1:57848] AH01964: Connection to child 61 established (server localhost:443)
[Wed Jan 13 11:22:48.089864 2021] [wsgi:info] [pid 6032:tid 1292] [client ::1:57848] mod_wsgi (pid=6032, process='', application=''): Loading Python script file 'C:/wamp64/https_www/MMDBpy.wsgi'., referer: https://localhost/
[Wed Jan 13 11:22:48.103850 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] mod_wsgi (pid=6032): Failed to exec Python script file 'C:/wamp64/https_www/MMDBpy.wsgi'., referer: https://localhost/
[Wed Jan 13 11:22:48.103850 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] mod_wsgi (pid=6032): Exception occurred processing WSGI script 'C:/wamp64/https_www/MMDBpy.wsgi'., referer: https://localhost/
[Wed Jan 13 11:22:48.103850 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] Traceback (most recent call last):\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]   File "C:/wamp64/https_www/MMDBpy.wsgi", line 1, in <module>\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]     from MMDBA_Scripts.Dash_Server_Host import app as application\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]   File "C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\MMDBA_Scripts\\Dash_Server_Host.py", line 29, in <module>\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]     import pandas as pd\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]   File "C:\\Users\\Constantin\\anaconda3\\envs\\MMDBpy\\lib\\site-packages\\pandas\\__init__.py", line 16, in <module>\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]     raise ImportError(\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] ImportError: Unable to import required dependencies:\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] numpy: \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] Importing the numpy C-extensions failed. This error can happen for\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] many reasons, often due to issues with your setup or how NumPy was\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] installed.\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] We have compiled some common reasons and troubleshooting tips at:\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]     https://numpy.org/devdocs/user/troubleshooting-importerror.html\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] Please note and check the following:\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]   * The Python version is: Python3.8 from "C:\\wamp64\\bin\\apache\\apache2.4.46\\bin\\httpd.exe"\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848]   * The NumPy version is: "1.19.2"\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] and make sure that they are the versions you expect.\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] Please carefully study the documentation linked above for further help.\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.\r, referer: https://localhost/
[Wed Jan 13 11:22:48.104851 2021] [wsgi:error] [pid 6032:tid 1292] [client ::1:57848] \r, referer: https://localhost/

Regards

Kai

Graham Dumpleton

unread,
Jan 13, 2021, 5:04:22 PM1/13/21
to mod...@googlegroups.com
Are you able to find where the _multiarray_umath package/C extension is installed? What directory is it in?

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/5c100304-3bce-4e1f-8f3a-7ef9c95aa6b5n%40googlegroups.com.

Kai Brown

unread,
Jan 14, 2021, 7:14:23 AM1/14/21
to modwsgi
Hi Graham,

Thanks for the quick reply - I did a search for the _multiarry_umath_ and found this file in the numpy core folder.
Seems like it should be found as site-packages is on the module search path...

_multiarray_umath.PNG

Opening it just with notepad just reveals gibberish though. 
I tried importing numpy from console as well and that works fine:

NumpyTest.PNG

Regards

Kai

Graham Dumpleton

unread,
Jan 17, 2021, 7:35:15 PM1/17/21
to mod...@googlegroups.com
Did you get any further on this?

I don't have any simple answer. Anaconda Python is always a big problem as they do things in a way that breaks use of Python in embedded systems. The error from Windows doesn't help as what it may actually be saying is that a DLL required by _multiarray_umath extension can't be found/loaded and not that the extension file can't be found.

So if _multiarray_umath extension is linked to a DLL which is part of Anaconda Python installation and not in a system library directory it may not be finding it.

Are you able to use some Windows tool to determine what DLLs that _multiarray_umath.pyd file is requiring? If there are some which appear to be part of the Anaconda distribution, where are they located?

Graham

On 14 Jan 2021, at 11:14 pm, Kai Brown <kaibr...@gmail.com> wrote:

Hi Graham,

Thanks for the quick reply - I did a search for the _multiarry_umath_ and found this file in the numpy core folder.
Seems like it should be found as site-packages is on the module search path...

<_multiarray_umath.PNG>

Opening it just with notepad just reveals gibberish though. 
I tried importing numpy from console as well and that works fine:

To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/70d80b23-522e-4a74-ae1d-60fb73616092n%40googlegroups.com.
<_multiarray_umath.PNG><NumpyTest.PNG>

Kai Brown

unread,
Jan 18, 2021, 1:50:22 AM1/18/21
to modwsgi
I did not get any further no - in the days since posting I found all the threads criticizing anaconda python, and have since successfully launched my app with an ubuntu virtual machine.

Thanks for the help on this Graham, I will just write off anaconda for web development and reinstall vanilla python if I need to code on windows again.

Regards

Kai

Reply all
Reply to author
Forward
0 new messages