コミュニティ
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to Install Numpy

6件の返信6
返信
メッセージ1/7
Anonymous
2596 件の閲覧回数, 6 件の返信

How to Install Numpy

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.

6件の返信6
メッセージ2/7
marshaltu
次のアカウントへの返信: Anonymous

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



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

メッセージ3/7
Anonymous
次のアカウントへの返信: marshaltu

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.

メッセージ4/7
ross.korsky
次のアカウントへの返信: Anonymous

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. 

メッセージ5/7
Anonymous
次のアカウントへの返信: ross.korsky

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.

メッセージ6/7
ross.korsky
次のアカウントへの返信: Anonymous

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.

メッセージ7/7
goutam_reddy
次のアカウントへの返信: Anonymous

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

お探しの情報が見つからないときは、コミュニティで質問しましょう。困っている人がいたら、情報を教えてあげましょう。

フォーラムに投稿  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report