Successfully resolved SyntaxError: import * only allowed at module level

Successfully resolved SyntaxError: import * only allowed at module level

 

 

table of Contents

Solve the problem

Solutions

Solution


 

 

Solve the problem

 

 

Solutions

Syntax error: Only import at module level *

 

 

Solution

Within the def function, don't use the following usage, just put it outside the function!

def ML5_Re_Plot():
    from sklearn.linear_model import LinearRegression

Should be changed to

from sklearn.linear_model import LinearRegression
def ML5_Re_Plot():
    

 

 

 

 

Published 1672 original articles · praised 7504 · visits 13.55 million +

Guess you like

Origin blog.csdn.net/qq_41185868/article/details/105649257