Alot of people have had a similar issue with failing to find "mtrand" when running the numpy test file for ghpyhton, even after numpy has been correctly installed and built and the path to numpy is returned when running. From a ghpython module, from editPythonScript in Rhino, or the IronPython terminal confirm python knows where to look:
import sys
print sys.path
You should get something like:
['C:\\Users\\you\\AppData\\Local\\Temp', 'C:\\Program Files (x86)\\Rhinoceros 5.0 90-Day Evaluation\\Plug-ins\\IronPython\\Lib', 'C:\\Users\\you\\AppData\\Roaming\\McNeel\\Rhinoceros\\5.0\\Plug-ins\\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\\settings\\lib', 'C:\\Users\\you\\AppData\\Roaming\\McNeel\\Rhinoceros\\5.0\\scripts', 'C:\\Program Files (x86)\\IronPython 2.7\\Lib\\site-packages', 'C:\\Program Files (x86)\\IronPython 2.7\\DLLs']
If you still get "mtrand" and cannot find "numpy" exceptions, you can try to be more explicit in your code to direct python where to look. For whatever reason this allows python to get around the exceptions. Try:
import sys
print sys.path
sys.path.append(r'c:\Program Files (x86)\IronPython 2.7')
sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\DLLs')
sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\Lib')
sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\Lib\site-packages')
import clr
clr.AddReference('mtrand.dll')
import numpy
print numpy.__version__
This should return the version of numpy you are using, which confirms that python can see numpy and everything is working.
(See here for more info).
Giulio Piacentino
Thanks for posting this Kendra!
A similar method to add the path used by the Enthought installer is also explained by Steve here: http://stevebaer.wordpress.com/2011/06/27/numpy-and-scipy-in-rhinop...
Cheers,
- Giulio
_________________
giulio@mcneel.com
Jun 11, 2012
Yuko Ishizu
You saved my day!! Thank you very much for sharing this!!
Jun 9, 2016