Importing UTM Library in RhinoPython

Hi all

I’m trying to use the utm library from here: utm · PyPI

  1. I installed python3

  2. I installed utm through the windows command line

  3. Update module search paths in Rhino python editor

  4. Restarted Rhino + Restarted computer

  5. utm is not loaded when I import it

However, this was working just yesterday and I have not changed anything. I instlled pandas through the command line but that shouldn’t break it right

Any suggestions would be much appreciated

btw, I can run utm through python, just no longer in Rhion

Hello- Rhino 7 uses IronPython, 2/.7 I think - Python 3.9 is in the V8 WIP , I do not know if that library will work but I imagine so.


Hi Pascal, i also thought about the python version, but the utm library was working in rhino and grasshopper before today so i don’t understand what has changed. I’m running rhino 7

I’d guess that perhaps numpy got installed by pandas, and that may fail with IronPython. The utm module will try to import numpy if it is available.

Anyway, instead of relying on code completion just do

import utm

If it prints the module path without problem then import worked just fine. That code completion doesn’t work doesn’t mean that the module wasn’t imported and incapacitated.

by default pip installs utm at:

but i get this message when I Print(utm)

so I cut/paste the utm folders to:C:\Program Files\Python310\Lib\site-packages
also relink in rhino python editor and then it will work

*also need to delete the old path to appdata

dont’ understand why it can’t read the path in appdata

Someone else had this same error earlier this week.

utm attempts to support numpy data types, but will fall back to a core math library otherwise. This fallback path is what’s needed in RhinoPython.

However if anything has exposed certain versions of CPython numpy to Rhino Python, then when you import numpy you will recreate that “unexpected token ‘from’” error. It’s not a from in an import from or from X import Y, it’s CPython 3 syntax raise Z from W, because after a certain version numpy dropped Python 2 compatibility.

numpy would always fail to import or function in RhinoPython as soon as it hits compiled C-code. The only unusual thing here is the strange “from” token error masking the real issue.

I made a patch for the utm in shrimpGIS. Give me about an hour and I’ll upload a version of utm that doesn’t use numpy.

Hi David. If you’re still having this problem, you can try this version of utm with all the numpy stripped out. It’s not on PyPi but is still installable locally using pip but you have to download it, unzip it and pip install .

Big Thank you James,

Do I put the utm-no-numpy-0.7.1 folder here:

I would let pip install it there for you, and create a new folder somewhere else.

sorry, how do I download it and pip install locally? I am very noob :sweat_smile:

No worries. I didn’t realise had produced a .tar.gz, was that the problem?

It’s on PyPi for you now anyway.

This is the first package I’ve put on there. I can install it into a venv, but please can you do me a favour and let me know if the commands below work?:

pip install utm-no-numpy

>>> import utm_no_numpy


@James_Parrott, Those commands work

I do a import of both, just in case it works for some people and they don’t have the no numpy version

Excellent - thanks David.

By the way there’s no need to alias an import with the same name it’s imported with. And in that try block, you should try and catch the syntax error only “unexpected token from”. This won’t mask all other possible errors that might occur in import utm, and can then let your users know what the fix is too.

    import utm
except SyntaxError:
    import utm_no_numpy
1 Like