Hello, I have a question on how to import Numpy.
I've seen two other posts about this issue but none have worked for me.
I've pip installed Numpy, and is in my system's Path variable but I keep getting the "No module named 'numpy'" error.
In my system I have numpy version 1.13.1 installed in Windows 10 64bit system.
Hello,
I assume you were getting the error when you run script or addin in Fusion 360. If so, it was because Fusion 360 had own Python under install folder. You may have to put the library to that folder as below. Meanwhile the install folder of Fusion 360 may be changed after it is upgraded to new version. So the best practice would be to put the library to the folder which your script or addin is located at. The advantage is that your users needn't install the library again when you deliver your script to addin to them.
"C:\Users\<User>\AppData\Local\Autodesk\webdeploy\Production\<blablabla>\Python\Lib\site-packages"
Thanks,
Marshal
Thank you.
I tried doing "pip install numpy -t file_directory" where the file_directory was the one you mentioned and it installed numpy in the directory but now it is giving me an error: "importerror: cannot import name 'multiarray'". So it seems like it worked but now I just need to debug this error now.
You can also create a directory LINK to the library.
Open the command prompt / shell and Execute from directory you wish to create the link within
mklink /J numpy C:\some\path\to\the\numpy\folder
Then in your scripts you need to use relative imports like so (notice the leading dot)
from .numpy import Something
import .numpy
The cool part about this solution is that if you ZIP up your project folder the linked libraries are simply included in the ZIP (at least they are with 7zip) and you can have multiple projects all "linked" to the same libraries and not have to worry about keeping all of your projects up to date with the latest version of that library.
Ok, i did the command you said to use.
and when I tried using "import .numpy", it said syntax error, pointing at the period right before numpy.
so then, I tried "from .numpy import all as np", because I would like all the functions from numpy to be imported and I got
"ImportError: No module named '__main__C%3A%2FUsers%2F...."
Thank you though.
I was on a business trip for a few days, home now...
It looks like the correct syntax, when using the folder link, is:
from . import numpy as np
However, this alone won't work as numpy requires the building of extension modules written in C (normally done as part of the numpy setup/install). Even if you get around this (likely by hacking at the __init__.py file in the numpy dir) you'll have a servery limited numpy (with none of the C modules), or a non-portable Fusion extension (with the C modules built for your platform), at best..
I'm not sure how to proceed from here - but if you figure it out i'm interested too.
It's 2024- Any updates on how to do this? Would make for much more powerful scripts / add-ins if we could reliable import numpy/scipy / etc...
お探しの情報が見つからないときは、コミュニティで質問しましょう。困っている人がいたら、情報を教えてあげましょう。