Error importing numpy: you should not try to import numpy...

9,480 views
Skip to first unread message

Rudi Hammad

unread,
Jun 14, 2020, 6:00:59 PM6/14/20
to Python Programming for Autodesk Maya
Hi,
I am on maya 2018 and windos 10 x64. I have looking in the forum how to install numpy and I did the following:
To check which numpy version I need I went to https://www.lfd.uci.edu/~gohlke/pythonlibs/

And I get the error:

# Error: Error importing numpy: you should not try to import numpy from
#         its source directory; please exit the numpy source tree, and relaunch
#         your python interpreter from there.
# Traceback (most recent call last):
#   File "<maya console>", line 4, in <module>
#   File "C:\Program Files\Autodesk\Maya2018\Python\lib\site-packages\numpy\__init__.py", line 131, in <module>
#     raise ImportError(msg)
# ImportError: Error importing numpy: you should not try to import numpy from
#         its source directory; please exit the numpy source tree, and relaunch
#         your python interpreter from there. #

After googling the error none of the solutions I read work for me.
Any advice?

thanks

Rudi Hammad

unread,
Jun 14, 2020, 6:09:32 PM6/14/20
to Python Programming for Autodesk Maya
never mind, I tried to delete numpy folder to start clean, and I can't pip install anymore.
Error: could not install packages due to an EnvironmentError: ...
I give up for today

Rudi Hammad

unread,
Jun 14, 2020, 6:24:30 PM6/14/20
to Python Programming for Autodesk Maya
one last thing. downloaded manually the numpy and scipy for the link and when to the folder and did pip install.
I did install but not I get the error: # Original error was: DLL load failed: %1 is not a valid Win32 application. #
So I thought that maybe it had to download numpy-1.16.6+mkl-cp27-cp27m-win_amd64.whl, but that doesn't even intall . I get the error

ERROR: numpy-1.16.6+mkl-cp27-cp27m-win_amd64.whl is not supperted wheel on this platform.

so....what am I supposed to to now?

Deke Kincaid

unread,
Jun 14, 2020, 7:49:02 PM6/14/20
to python_in...@googlegroups.com
You installed the 32 bit version in your first email which is why it was erroring in the first place.  This is signified by the “-win32” at the end of the name.  How did you uninstall it?  I’m suspecting there is some left over part from the previous install?

I would use the vanilla amd64 version as the mkl version needs Intel’s MKL library installed which is not free.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/73293d32-3135-462f-956a-335e1c78d848o%40googlegroups.com.

Rudi Hammad

unread,
Jun 14, 2020, 8:49:45 PM6/14/20
to Python Programming for Autodesk Maya
I deleted and installed again python.
So this is what I did this time:

1-download numpy-1.16.6+vanilla-cp27-cp27m-win_amd64.whl
2-opened cmd, and when to my download path and run pip install numpy-1.16.6+vanilla-cp27-cp27m-win_amd64.whl
3-it said instalation successfull (except some pandas and matplotlib errors)
4-i checked C:\Python27\Lib\site-packages and I saw that numpy was there, so I guess installation went fine

and then in maya I do this:

import sys
sys
.path.append(r"C:\Python27\Lib\site-packages")
import numpy

and I get this error

# IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
#
# Importing the multiarray numpy extension module failed.  Most
# likely you are trying to import a failed build of numpy.
# Here is how to proceed:
# - If you're working with a numpy git repository, try `git clean -xdf`
#   (removes all files not under version control) and rebuild numpy.
# - If you are simply trying to use the numpy version that you have installed:
#   your installation is broken - please reinstall numpy.
# - If you have already reinstalled and that did not fix the problem, then:
#   1. Check that you are using the Python you expect (you're using C:\Program Files\Autodesk\Maya2018\bin\maya.exe),
#      and that you have no directories in your PATH or PYTHONPATH that can
#      interfere with the Python and numpy versions you're trying to use.
#   2. If (1) looks fine, you can open a new issue at
#      https://github.com/numpy/numpy/issues.  Please include details on:
#      - how you installed Python
#      - how you installed numpy
#      - your operating system
#      - whether or not you have multiple versions of Python installed
#      - if you built from source, your compiler versions and ideally a build log
#
#      Note: this error has many possible causes, so please don't comment on
#      an existing issue about this - open a new one instead.
#
# Original error was: DLL load failed: The specified module could not be found. #


and then, if i do again  import numpy, I get this error

Introducir código aquí...# Error: cannot import name _distributor_init

# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
#   File "C:\Python27\Lib\site-packages\numpy\__init__.py", line 140, in <module>
#     from . import _distributor_init
# ImportError: cannot import name _distributor_init #

So I am completly lost.

Is it possible that it is I am running maya 2018.6 instead of 2018?

Rudi Hammad

unread,
Jun 14, 2020, 10:09:50 PM6/14/20
to Python Programming for Autodesk Maya
By the way, everything is fine in pycharm if I set the interpreter as C:\Python27\python.exe
So numpy is not boken. It is mayapy that is not happy with numpy

Marcus Ottosson

unread,
Jun 15, 2020, 2:54:44 AM6/15/20
to python_in...@googlegroups.com
There are at least two problems. 

- First, remember that the official Python != Maya's Python. The version of NumPy you've got is built for the official Python, and you need one for Maya's Python. How can you get that? The interwebs could lead you to a copy someone has built, or you can build it yourself using `mayapy` in place of `python`.
- Second, if you *were* going to use the official Python version (which probably won't work), make sure it's 64-bit like Deke said. It must match your Maya version. My guess is that's where your DLL error comes from. But again, official Python != Maya's Python.

The reason PyCharm works is because PyCharm == official Python, so everything is well. Anytime you're dealing with compiled modules, like NumPy, and want to use them in Maya, you'll need them compiled for Maya's Python.

On Mon, 15 Jun 2020 at 03:09, Rudi Hammad <rudih...@gmail.com> wrote:
By the way, everything is fine in pycharm if I set the interpreter as C:\Python27\python.exe
So numpy is not boken. It is mayapy that is not happy with numpy

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Rudi Hammad

unread,
Jun 15, 2020, 3:43:14 AM6/15/20
to Python Programming for Autodesk Maya
I see, thanks for the explanation.
The error is coming having installed the 64 bits vanilla version that deke suggested,
I found this link and it seems to work for people who tried it: https://drive.google.com/drive/folders/0BwsYd1k8t0lEMjBCa2N1Z25KZXc
but I didn't it didn't for me. Not sure what I am doing wrong.Actually, I don't really understand what pyHook and numexpr are supposed to be doing, so there must be some bit of information that I didn't quite get.
So I'll just write my math libraries using python's default for now and maybe refactor in the future if I manage to make it work.

El domingo, 14 de junio de 2020, 23:54:44 (UTC-7), Marcus Ottosson escribió:
There are at least two problems. 

- First, remember that the official Python != Maya's Python. The version of NumPy you've got is built for the official Python, and you need one for Maya's Python. How can you get that? The interwebs could lead you to a copy someone has built, or you can build it yourself using `mayapy` in place of `python`.
- Second, if you *were* going to use the official Python version (which probably won't work), make sure it's 64-bit like Deke said. It must match your Maya version. My guess is that's where your DLL error comes from. But again, official Python != Maya's Python.

The reason PyCharm works is because PyCharm == official Python, so everything is well. Anytime you're dealing with compiled modules, like NumPy, and want to use them in Maya, you'll need them compiled for Maya's Python.

On Mon, 15 Jun 2020 at 03:09, Rudi Hammad <rudih...@gmail.com> wrote:
By the way, everything is fine in pycharm if I set the interpreter as C:\Python27\python.exe
So numpy is not boken. It is mayapy that is not happy with numpy

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Marcus Ottosson

unread,
Jun 15, 2020, 4:31:36 AM6/15/20
to python_in...@googlegroups.com
From what I gather, numexpr and pyhook are other Python libraries?


They won't help you get NumPy installed if that's what you're thinking. I think the reference you found was maybe this?


If so, that's from 5 years ago and it's likely the contents of that folder has changed since then.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9ad4f036-8455-4e0d-9fc1-fcb13f0e635fo%40googlegroups.com.

Rudi Hammad

unread,
Jun 15, 2020, 1:10:36 PM6/15/20
to Python Programming for Autodesk Maya
Numexpr uses numpy at somepoint, but you' re right, they don't anything regarding numpy.
I didn't saw that link, I am going to give a try, thx.

El lunes, 15 de junio de 2020, 1:31:36 (UTC-7), Marcus Ottosson escribió:
From what I gather, numexpr and pyhook are other Python libraries?


They won't help you get NumPy installed if that's what you're thinking. I think the reference you found was maybe this?


If so, that's from 5 years ago and it's likely the contents of that folder has changed since then.

On Mon, 15 Jun 2020 at 08:43, Rudi Hammad <rudih...@gmail.com> wrote:
I see, thanks for the explanation.
The error is coming having installed the 64 bits vanilla version that deke suggested,
I found this link and it seems to work for people who tried it: https://drive.google.com/drive/folders/0BwsYd1k8t0lEMjBCa2N1Z25KZXc
but I didn't it didn't for me. Not sure what I am doing wrong.Actually, I don't really understand what pyHook and numexpr are supposed to be doing, so there must be some bit of information that I didn't quite get.
So I'll just write my math libraries using python's default for now and maybe refactor in the future if I manage to make it work.

El domingo, 14 de junio de 2020, 23:54:44 (UTC-7), Marcus Ottosson escribió:
There are at least two problems. 

- First, remember that the official Python != Maya's Python. The version of NumPy you've got is built for the official Python, and you need one for Maya's Python. How can you get that? The interwebs could lead you to a copy someone has built, or you can build it yourself using `mayapy` in place of `python`.
- Second, if you *were* going to use the official Python version (which probably won't work), make sure it's 64-bit like Deke said. It must match your Maya version. My guess is that's where your DLL error comes from. But again, official Python != Maya's Python.

The reason PyCharm works is because PyCharm == official Python, so everything is well. Anytime you're dealing with compiled modules, like NumPy, and want to use them in Maya, you'll need them compiled for Maya's Python.

On Mon, 15 Jun 2020 at 03:09, Rudi Hammad <rudih...@gmail.com> wrote:
By the way, everything is fine in pycharm if I set the interpreter as C:\Python27\python.exe
So numpy is not boken. It is mayapy that is not happy with numpy

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Rudi Hammad

unread,
Jun 15, 2020, 2:22:57 PM6/15/20
to Python Programming for Autodesk Maya
yes! it works!
thanks marcus, I just pip installed what was said in that link and it just work. awesome, you saved me a lot of frustration.

Marcus Ottosson

unread,
Jun 15, 2020, 2:55:36 PM6/15/20
to python_in...@googlegroups.com
I'm glad it works, but that's not what I meant. xD

I had a closer look at the link, and assume you're referring to that last post?

```py
```

That still isn't the right way to do it, as it would fetch a build of NumPy built for the official Python, whereas what you need is a build *specifically for your version of Maya*. I don't know how to express this any clearer, haha. What I expect you'll find with that version is that it *may* work some of the time, and other times you'll experience intermittent crashes and segmentation faults, due to calling on a compiled library built for a different runtime. I'm having trouble drawing a parallel to anything else for more clarity, perhaps someone else can help me out?

I had to experience this first-hand before it made any sense to me, so odds are you are in for the same ride. Just don't put it in production or release any software with it, haha. Think of the children.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/075e4f58-8494-4dc3-afa6-93b45b0fc856o%40googlegroups.com.

Rudi Hammad

unread,
Jun 15, 2020, 3:39:19 PM6/15/20
to Python Programming for Autodesk Maya
yes, that's the pip install that worked.  same with scipy
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages