Numpy for Iron Python with ghpython / mtrand exceptions

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).