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.
Solved! Go to Solution.
Solved by Jorge_Jaramillo. Go to Solution.
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.
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'
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
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!
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
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:
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.
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.
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!
Can't find what you're looking for? Ask the community or share your knowledge.