I.e., I can import fine the file mymod.py having content:
def search(words):
"""Return list of words containing 'son'"""
newlist = [w for w in words if 'son' in w]
return newlist
But, I cannot import the file mymod2.py having content:
def search(words):
"""Return list of words containing 'son'"""
import numpy as np
newlist = [w for w in words if 'son' in w]
return newlist
Here is what I was doing in Matlab, together with the error messages:
>> py.importlib.import_module('mymod2')
ans =
Python module with properties:
search: [1×1 py.function]
<module 'mymod2' from 'mymod2.py'>
>> N = py.list({'Jones','Johnson','James'})
N =
Python list with no properties.
['Jones', 'Johnson', 'James']
>> py.mymod2.search(N)
Error using _init_><module> (line 26) Python Error: ImportError: Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try `git clean -xdf` (removes all files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
Error in type_check><module> (line 11) import numpy.core.numeric as _nx
Error in _init_><module> (line 8) from .type_check import *
Error in add_newdocs><module> (line 13) from numpy.lib import add_newdoc
Error in _init_><module> (line 153) from . import add_newdocs
Error in mymod2>search (line 3) import numpy as np
I cannot figure out why. More details below on what I tried.
This works: system('C:\Users\BobbyWatson\AppData\Local\Enthought\Canopy\edm\envs\User\python D:\MyPath\mymod2.py')
When I run [v, e, i] = pyversion I get:
v =
2.7
e =
C:\Users\BobbyWatson\AppData\Local\Enthought\Canopy\edm\envs\User\python.exe
i =
(Which I did set up myself.)