Run External Python file .py from Dynamo

i created a python .py file in VsCode and i want to make dynamo run this .py file without need to re-write it again inside Dynamo ?

thanks in advance

Have a look at these nodes:

  • Python Script From String
  • ReadText

@Andreas_Dieckmann

File.FromPath is another node you’ll need for this… :wink:

i tried both and same problem :sunglasses:

Looks like its the issue in the code. Haven’t looked the complete though. Python Script from String should work directly with string. Try adding this:

import os

Almost there :wink:

@Martin_Spence1 is right. Add File.FromPath and File.ReadText.

Then there is the issue of your code not actually being written properly which @Kulkul refers to. Your code has compilation errors. These need to be addressed.

If import os doesn’t do the trick you might be missing a reference to C:\ProgramFiles\Iron Python 2.7\Libs

To summarize, just keep an eye on all references. They might be working file in external IDE like Visual Studio, but Dynamo might not have the same references loaded in by default, so you have to be explicit.

2 Likes

This is related and might be of help: