0

The conda environment with numpy and gmpy2 packages was created using

conda create --name py4mat python=3.9 numpy gmpy2

Created environment was tested using

PS C:\_users\rad> conda activate py4mat
(py4mat) PS C:\_users\rad> python
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:28:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import gmpy2
>>>

In Matlab, the environment was loaded using

>> pyversion("C:\Users\labuser\.conda\envs\py4mat\python.exe")
>> pyenv
ans = 
  PythonEnvironment with properties:

          Version: "3.9"
       Executable: "C:\Users\labuser\.conda\envs\py4mat\python.exe"
          Library: "C:\Users\labuser\.conda\envs\py4mat\python39.dll"
             Home: "C:\Users\labuser\.conda\envs\py4mat"
           Status: NotLoaded
    ExecutionMode: InProcess
>> 

However when trying to load modules, the gmpy2 raises import error:

>> py.importlib.import_module('numpy');
>> py.importlib.import_module('gmpy2');
Error using __init__><module> (line 1)
Python Error: ImportError: DLL load failed while importing gmpy2: The specified procedure could not be
found.
Error in <frozen importlib>_call_with_frames_removed (line 228)

Error in <frozen importlib>exec_module (line 850)

Error in <frozen importlib>_load_unlocked (line 680)

Error in <frozen importlib>_find_and_load_unlocked (line 986)

Error in <frozen importlib>_find_and_load (line 1007)

Error in <frozen importlib>_gcd_import (line 1030)

Error in __init__>import_module (line 127) 
rad
  • 157
  • 1
  • 9
  • Have you tried using [conda --prefix](https://docs.conda.io/projects/conda/en/stable/commands/create.html) method to create a local working directory? – X Zhang Mar 20 '23 at 12:59
  • @XZhang Specifying prefix did not help. – rad Mar 22 '23 at 14:08
  • It's probably not an out-of-factory problem. I used a very similar script to yours, it's working well on my end. – X Zhang Mar 24 '23 at 01:56

0 Answers0