Note that Revit and Dynamo both have Line class, and so if you’ve loaded both of them into the Python environment it’s likely that you’re confusing the computer which is preventing it from knowing what to do (Revit Line doesn’t have that method, but you didn’t say to use Dynamo Line and so I’m trying the ‘first in mind’ which happens to be Revit due to the complexity of that library).
If not that it’s likely an imports error.
You need to share the simplest reproducible code sample here for more direct support (i.e. if the option which @staylor shared doesn’t work).