0

Additional Python modules in Micromine

Steve 4 months ago in Scripting updated 4 months ago 1

Can anyone tell me how I can use external python modules (e.g. numpy, pandas) in Micromine scripts? 

I have miniconda installed (I'm familiar with using conda to manage different environments outside of Micromine) and I've tried setting 'External Python Module Repository Paths' in the Micromine script editor to point to a folder containing numpy but the numpy import fails with the message below. I've followed the doc links in the message but I can't work out what the problem is.


IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

* The Python version is: Python3.8 from "C:\Program Files\Micromine Origin & Beyond 2022.5\mmwin.exe"
* The NumPy version is: "1.23.3"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
File "C:\Offline Files\EGY\MmData\EDX\PyScripts\test.py", line 11, in
import numpy as np

File "C:\Program Files\Micromine Origin & Beyond 2022.5\Python\lib\site-packages\numpy\__init__.py", line 140, in
from . import core

File "C:\Program Files\Micromine Origin & Beyond 2022.5\Python\lib\site-packages\numpy\core\__init__.py", line 49, in
raise ImportError(msg)

+2

Fixed it by installing Python3.8 and then installing pandas by running "py -3.8 -m pip install pandas" in a cmd window. Then pointed Micromine to the pandas installation by opening 'Script Options' and set  'External Python repository Path'  to "...AppData\Local\Programs\Python\Python38\Lib\site-packages" (the location of the Py3.8 pandas install). All now works, can import pandas in a Micromine script.