Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
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.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to run any scripts: Module not found error adsk.core

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
jeg6BMD5N
623 Views, 8 Replies

Unable to run any scripts: Module not found error adsk.core

I am suddenly unable to run any of my existing scripts which previously functioned just fine in fusion due to this error. Most forum posts that show this issue are simply because they are not running the script from fusion, or in the vscode instance created by fusion with the debugger. This is not the case for me.

I experienced this issue once before when I found my VS Code editor was automatically updating the python interpreter. I fixed it before by following the steps in this forum post; changing the interpreter and adding adsk.core to path and restarting fusion/vscode.

 

I now suddenly am getting what I believe is the same problem again, but changing the interpreter and adding the adsk.core path to environment variables has not fixed anything.

I even went so far as to uninstall VS Code, and python, and remove all of the folders with any associated data. I then let fusion install python and vs code and set up the environment from scratch... and I get the same error. I am so confused how starting completely from scratch will not yield a functional setup. I do some coding outside of fusion that requires different python versions and packages so I was hoping to have some kind of profile in vs code with the proper settings that won't be changed when I update my other environments, but I am not sure that is possible with fusion. 

 

Any insight would be very much appreciated. I am at my wits end with trying to figure this one out. I will attach pictures of the errors I am seeing below.

error1.png

Labels (1)
8 REPLIES 8
Message 2 of 9
Jorge_Jaramillo
in reply to: jeg6BMD5N

Hi,

 

Just to help with some debug, could you add the following snippet at the very beginning of your script and post the results:

import sys
print(f'{sys.version=}')
print(f'{sys.path=}')
print(f'{sys.executable=}')

 

regards.

Message 3 of 9
jeg6BMD5N
in reply to: Jorge_Jaramillo

Thank you for your reply, here is the output of the requested code:

 

sys.version='3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]'
sys.path=['c:\\Users\\Jeff-laptop\\AppData\\Roaming\\Autodesk\\Autodesk Fusion 360\\API\\Scripts\\Export Points', 'C:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Api\\Python\\packages', 'c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python\\python311.zip', 'c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python\\Lib', 'c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python\\DLLs', 'c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python', 'c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python\\Lib\\site-packages']
sys.executable='c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\Python\\python.exe'

 

Message 4 of 9
Jorge_Jaramillo
in reply to: jeg6BMD5N

Hi,

 

Very extrange.

In my case the sys.executable is:

C:/Users/Usuario/AppData/Local/Autodesk/webdeploy/production/4826aec956713f599d57385857ff62484fd50dd3/Python\python

It is similar to your, but without the .exe extension.

 

I believe your Fusion installation is broken.

 

Regards,

Jorge Jaramillo

 

Message 5 of 9

One thing I didn't notice when read your response:
the Fusion's main directory is not in the sys.path
This directory contains many DLLs.
Can you try adding it with:
sys.path.append()

And one more question:
what do you have in lines 1 to 3 in your script? (I see the error comes from line 4 in your script).

Message 6 of 9
jeg6BMD5N
in reply to: Jorge_Jaramillo

Thank you for your insights on this, and apologies for the delay in my response over the weekend.

 

Line 4 of my script is the default line created by fusion importing the Autodesk libraries adsk.core etc. Lines 1-3 contain comments. This error still happens even with a fresh installation of Fusion, as well as on my second computer. This makes me think it is not the installation that is broken, but something I am doing.

 

You mentioned before that I may be running the script out of the normal Fusion environment. You may be correct; with the script i was testing, nothing would happen when running it using the green start button within Fusion. So, I attempted to debug by running with debugger in VS Code (which I have done before with no issues). I tested this with a new default Hello World script and it runs okay within Fusion using the green start button, but I receive the same module error when running debugger in vs code. So I need to figure out why running with the debugger in vs code no longer works and why my other script does not attempt to run when running in Fusion.

 

Could you please elaborate on what main directory you are asking me to add with sys.path.append()? The path where Fusion.exe is? I do not see any DLLs in that folder. Sorry if that is a silly question

 

Thanks!

Message 7 of 9
Jorge_Jaramillo
in reply to: jeg6BMD5N

Hi,

 

You mentioned before that you deal with scripts in different Python version.  Which utility do you use to switch between them?

It is extrange that the debugger started from Fusion doesn't provide the right environment for the script to run.

Could you post you .vscode/settings.json file?  Maybe there is something there that is not correct.

 

Regarding the sys.path, add the following lines at the very beginning of your script:

import sys
sys.path.append("c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3")

After adding this to your script, give it a try both Fusion and from the debugger, and lets see your results.

 

And about the DLL files: "c:\\Users\\Jeff-laptop\\AppData\\Local\\Autodesk\\webdeploy\\production\\4826aec956713f599d57385857ff62484fd50dd3\\"  is the Fusion main directory in Windows installation.

Are you running it on Windows or Mac?  I believe it is Win, but just to check.

 

Regards,

Jorge Jaramillo

 

Message 8 of 9
jeg6BMD5N
in reply to: Jorge_Jaramillo

When I navigate to the folder where settings.json should be, it is absent. When I open the settings.json in VS Code itself it is blank as shown below:

jeg6BMD5N_0-1723421896747.png

I switch python versions/interpreters with the button in the bottom right tool bar that says the python version.

 

However, I did just figure something out. I have just been using this debug button in the top right of VS Code to run.

jeg6BMD5N_1-1723487545060.png

But I just switched the option in the drop down menu on the left side bar to Python Attach instead of Python Debugger and now it seems to run the Hello world script without issue.

jeg6BMD5N_2-1723487751074.png

I am not sure if this is supposed to be the default and I somehow changed it by mistake? Again, I uninstalled python and VS Code and let Fusion set it up and simply ran with the debug button. So I am a little confused why that got screwed up.

 

Thank you for helping me to troubleshoot this. Now I just need to figure out how to install/import python libraries to the correct python folder used by Fusion, but that is a separate issue.

 

Thanks again!

Message 9 of 9
Jorge_Jaramillo
in reply to: jeg6BMD5N

Hi,
Choosing "Phyton Debugger..." launch a new Python process and attach the debugger to it.
The option "Python: Attach" is the on you should use to debug Fusion scripts; its definition is defined on the file .vscode/launch.json to instruct VSCode how to attach to the Fusion environment.

On this URL on the API documentation is all information about Python in Fusion: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-743C88FB-CA3F-44B0-B0B9-FCC378D0D782

Regarding loading other python modules within Fusion, there are some topics in this forum that can help you.
Good Luck!.

Regards,
Jorge Jaramillo

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report