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

hajime2MRG3
Enthusiast
Enthusiast

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

hajime2MRG3
Enthusiast
Enthusiast

スクリーンショット 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?

1 Like
Reply
Accepted solutions (1)
1,621 Views
9 Replies
Replies (9)

KarlRBS
Explorer
Explorer
Accepted solution

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!

6 Likes

hajime2MRG3
Enthusiast
Enthusiast

It worked like a charm! Thank you!

0 Likes

OceanHydroAU
Collaborator
Collaborator

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.

1 Like

JeromeBriot
Mentor
Mentor

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

 

 

1 Like

en9y37
Advocate
Advocate

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

0 Likes

JeromeBriot
Mentor
Mentor

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.

0 Likes

GAAS.Design
Observer
Observer

edit: still broken

0 Likes

erik_per_rosen
Observer
Observer

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

0 Likes

BrianEkins
Mentor
Mentor

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
1 Like