Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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: 

Cannot launch VSCode by "Scripts and Add-ins" -> "Edit"

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
hajime2MRG3
1584 Views, 9 Replies

Cannot launch VSCode by "Scripts and Add-ins" -> "Edit"

スクリーンショット 2024-04-05 100556.png

The "Edit" button should launch VSCode. But now, it doesn't. I found it with my Windows 11, and verified with Windows 11 Enterprise Evaluation (here) on VirtualBox 7.0.12. VSCode has been changed something?

9 REPLIES 9
Message 2 of 10
KarlRBS
in reply to: hajime2MRG3

The same happened to me today. I believe it was a change in the just released v2024.4.0 of the VSCode python extension. Unfortunately, downgrading the extension to the previously working v2024.2.1 did not solve the problem for me. Luckily it was a fairly simple fix for me so we don't have to wait for Fusion to be updated.

All we have to do is edit the pre-run.py file to change "pythonFiles" to "python_files". This script can be found in Fusion by opening Preferences > API and navigating to the "Default Path for Scripts and Add-Ins." From here, we just need to navigate to the ./Python/vscode directory where the script is stored. On a Mac, the full path may look like "/Users/<username_goes_here>/Library/Application Support/Autodesk/Autodesk Fusion 360/API/Python/vscode/pre-run.py". Edit this file and find "pythonFiles" when setting msPythonPath and change it to "python_files". Restart Fusion and you should be good to go with v2024.4.0 of the ms-python.python extension. Here's the full difference:

+++ pre-run.py	2024-04-04
@@ -38,7 +38,7 @@
         msPythonPath = os.path.expandvars(msPythons[0][0].path)
         index = msPythonPath.rfind('.')
         version  = int(msPythonPath[index+1:])
-        msPythonPath = os.path.join(msPythonPath, 'pythonFiles', 'lib','python')
+        msPythonPath = os.path.join(msPythonPath, 'python_files', 'lib','python')
         msPythonPath = os.path.normpath(msPythonPath)
         if os.path.exists(msPythonPath) and os.path.isdir(msPythonPath):
             return msPythonPath

 

The reason for this change is described in the vscode-python changelog where it notes Issue #22921 "Rename pythonFiles to python_files". Hope that works for you too!

Message 3 of 10
hajime2MRG3
in reply to: hajime2MRG3

It worked like a charm! Thank you!

Message 4 of 10
OceanHydroAU
in reply to: hajime2MRG3

me too - worked fine thismorning, now I can't get anything done!

 

The above solution did nothing for me (Windows 10N)

** Update - you have to close and restart Fusion for this to start working.

 

Also fixes "debug":

pic_2024-04-05_17.52.41_482.png

 

It probably should not be marked as "Fixed" ... editing system files manually is a workaround - someone else really needs to find and fix the root problem here.

Message 5 of 10
JeromeBriot
in reply to: OceanHydroAU

The above fix did not completely resolve the issue on my PC (Windows 11). There was something wrong with the Python Debugger extension :

20240405T114111 I .15948 VSCode:Starting script run
20240405T114111 I .15948 VSCode:Python manager initializing
20240405T114111 I .15948 VSCode:Running script
20240405T114111 I .15948 VSCode:Python manager initializing
20240405T114111 I .15948 VSCode:Running python script
20240405T114111 E .15948 NUBASE.PYTHON: failed to start python debugger:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'debugpy'

20240405T114111 I .15948 VSCode:Launching visual studio code editor failed

 

I had to downgrade the "Python" extension and the "Python Debugger" extension in VS Code to version v2024.2.1 and to version v2024.2.0

 

 

Message 6 of 10
en9y37
in reply to: KarlRBS

It worked to me too. Thanks a lot!!!!

Message 7 of 10
JeromeBriot
in reply to: en9y37

On Windows, the pre-run.py file is located under :

 

C:\Users\<USERNAME>\AppData\Local\Autodesk\webdeploy\production\b6226a03d2af9e144aa8b1b7e17cf8eb0cd990f1\Python\vscode

 

If you don't find the b6226a03d2af9e144aa8b1b7e17cf8eb0cd990f1 folder, search for the newest one.

Message 8 of 10
GAAS.Design
in reply to: KarlRBS

edit: still broken

Message 9 of 10

Hey, I tried this but sadly it dosen't seem to work anymore. Is there some other solution?

Message 10 of 10
BrianEkins
in reply to: erik_per_rosen

See this post for a solution.

https://forums.autodesk.com/t5/fusion-api-and-scripts/can-t-edit-or-debug-my-python-scripts/m-p/1275...

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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

Post to forums  

Autodesk Design & Make Report