Fix My Tutorial
Report

Diving into data

Open the original tutorial
Fixed Python 3.12 · checked 17 Oct 2026 · model cost $0.037

The tutorial originally failed under Python 3.12 because it used Python‑2 style print statements and the removed `load_boston` function from scikit‑learn 1.2.0 (released 8 Dec 2022). After converting all print calls to function form and substituting the California housing dataset for the Boston dataset, the code runs successfully.

When it broke

Broke in scikit-learn 1.2.0, released 8 Dec 2022, according to the cited release notes. Older releases couldn't be run here to check. The tutorial was published in Nov 2014, so it worked for about 97 months.

Source: Code "from sklearn.datasets import load_boston" in 6-statistics.ipynb in Ordinary Least Squares Exercises Section is throwing Error in CoLab because `load_boston` has been removed from scikit-learn si

4 changes to make it work today

Run first code block: simple linear regression

s2 · run_code migrate

Add parentheses to print call to fix SyntaxError in Python 3.

@@ -22,3 +22,3 @@
for coef, name in lst)
-print "Linear model:", pretty_print_linear(lr.coef_)
+print("Linear model:", pretty_print_linear(lr.coef_))

Sources

  • Fix: "SyntaxError: Missing Parentheses in Call to 'print'" in Python - GeeksforGeeksThe `SyntaxError: Missing Parentheses in Call to 'print'` is a common error when transitioning from Python 2 to Python 3. It occurs because `print` is a function in Python 3, requiring parentheses around its arguments. By understanding this change and updating your code accordingly, you can avoid this error and ensure your Python code runs smoothly in the latest version of the language.
  • How to Fix 'SyntaxError: invalid syntax' in Python``` Problem: Python 2 style print statement print "Hello" # SyntaxError in Python 3 # Solution: Use print as a function print("Hello") # Problem: Python 2 style exception handling except Exception, e: # SyntaxError in Python 3 # Solution: Use 'as' keyword except Exception as e: ```

Run second code block: linear regression with correlated features

s3 · run_code migrate

Add parentheses to print call to fix SyntaxError in Python 3.

@@ -14,3 +14,3 @@
lr = LinearRegression()
lr.fit(X,Y)
-print "Linear model:", pretty_print_linear(lr.coef_)
+print("Linear model:", pretty_print_linear(lr.coef_))

Sources

  • Fix: "SyntaxError: Missing Parentheses in Call to 'print'" in Python - GeeksforGeeksThe `SyntaxError: Missing Parentheses in Call to 'print'` is a common error when transitioning from Python 2 to Python 3. It occurs because `print` is a function in Python 3, requiring parentheses around its arguments. By understanding this change and updating your code accordingly, you can avoid this error and ensure your Python code runs smoothly in the latest version of the language.
  • How to Fix 'SyntaxError: invalid syntax' in Python``` Problem: Python 2 style print statement print "Hello" # SyntaxError in Python 3 # Solution: Use print as a function print("Hello") # Problem: Python 2 style exception handling except Exception, e: # SyntaxError in Python 3 # Solution: Use 'as' keyword except Exception as e: ```

Run third code block: Lasso on Boston housing dataset

s4 · run_code migrate

Add parentheses to print call to fix SyntaxError in Python 3.; The Boston dataset was removed in scikit-learn 1.2 due to ethical concerns; the error message and deprecation notice recommend using fetch_california_housing as a drop-in replacement with the same Bunch interface (data, target, feature_names).

@@ -1,14 +1,14 @@
from sklearn.linear_model import Lasso
from sklearn.preprocessing import StandardScaler
-from sklearn.datasets import load_boston
+from sklearn.datasets import fetch_california_housing
-boston = load_boston()
+california = fetch_california_housing()
scaler = StandardScaler()
-X = scaler.fit_transform(boston["data"])
-Y = boston["target"]
-names = boston["feature_names"]
+X = scaler.fit_transform(california["data"])
+Y = california["target"]
+names = california["feature_names"]
lasso = Lasso(alpha=.3)
lasso.fit(X, Y)
-print "Lasso model: ", pretty_print_linear(lasso.coef_, names, sort = True)
+print("Lasso model: ", pretty_print_linear(lasso.coef_, names, sort = True))

Sources

  • Fix: "SyntaxError: Missing Parentheses in Call to 'print'" in Python - GeeksforGeeksThe `SyntaxError: Missing Parentheses in Call to 'print'` is a common error when transitioning from Python 2 to Python 3. It occurs because `print` is a function in Python 3, requiring parentheses around its arguments. By understanding this change and updating your code accordingly, you can avoid this error and ensure your Python code runs smoothly in the latest version of the language.
  • How to Fix 'SyntaxError: invalid syntax' in Python``` Problem: Python 2 style print statement print "Hello" # SyntaxError in Python 3 # Solution: Use print as a function print("Hello") # Problem: Python 2 style exception handling except Exception, e: # SyntaxError in Python 3 # Solution: Use 'as' keyword except Exception as e: ```
  • scikit-learn — PyHDFE 0.2.1 documentationC:\Programs\Anaconda\envs\pyhdfe\lib\site-packages\sklearn\utils\deprecation.py:87: FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2. The Boston housing prices dataset has an ethical problem. You can refer to the documentation of this function for further details. The scikit-learn maintainers therefore strongly discourage the use of this dataset unless the purpose of the code is to study and educate about ethical issues in data science and machine learning. In this special case, you can fetch the dataset from the original source::

Run fourth code block: Ridge regression stability test

s5 · run_code migrate

Add parentheses to all print calls to fix SyntaxError in Python 3.

@@ -5,5 +5,5 @@
#We run the method 10 times with different random seeds
for i in range(10):
- print "Random seed %s" % i
+ print("Random seed %s" % i)
np.random.seed(seed=i)
X_seed = np.random.normal(0, 1, size)
@@ -16,8 +16,8 @@
lr = LinearRegression()
lr.fit(X,Y)
- print "Linear model:", pretty_print_linear(lr.coef_)
+ print("Linear model:", pretty_print_linear(lr.coef_))
ridge = Ridge(alpha=10)
ridge.fit(X,Y)
- print "Ridge model:", pretty_print_linear(ridge.coef_)
- print
+ print("Ridge model:", pretty_print_linear(ridge.coef_))
+ print()

Sources

  • Fix: "SyntaxError: Missing Parentheses in Call to 'print'" in Python - GeeksforGeeksThe `SyntaxError: Missing Parentheses in Call to 'print'` is a common error when transitioning from Python 2 to Python 3. It occurs because `print` is a function in Python 3, requiring parentheses around its arguments. By understanding this change and updating your code accordingly, you can avoid this error and ensure your Python code runs smoothly in the latest version of the language.
  • How to Fix 'SyntaxError: invalid syntax' in Python``` Problem: Python 2 style print statement print "Hello" # SyntaxError in Python 3 # Solution: Use print as a function print("Hello") # Problem: Python 2 style exception handling except Exception, e: # SyntaxError in Python 3 # Solution: Use 'as' keyword except Exception as e: ```

Tell the author

Send them what broke and the fix, so the next reader doesn't hit the same error.

Badge

Add it to the tutorial so readers know when it was last checked.

Fix My Tutorial badge
Markdown
[![Fix My Tutorial](https://fix-my-tutorial.onrender.com/badge/ri-mVR6V5gp.svg)](https://fix-my-tutorial.onrender.com/r/ri-mVR6V5gp)
HTML
<a href="https://fix-my-tutorial.onrender.com/r/ri-mVR6V5gp"><img src="https://fix-my-tutorial.onrender.com/badge/ri-mVR6V5gp.svg" alt="Fix My Tutorial"></a>