algorithmic modeling for Rhino

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

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

Views: 3067

Reply to This

Replies to This Discussion

Thanks for posting this Kendra!

A similar method to add the path used by the Enthought installer is also explained by Steve here:


- Giulio

Thanks for adding that note, I forgot to mention that I definitely had set the paths through the "editPythonScript" method in Steve's post, but for whatever reason, my machine wouldn't let that pass. I'm from a unix background though, so who knows! K

You saved my day!! Thank you very much for sharing this!!






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2019   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service