After adding
from mpl_toolkits.mplot3d import Axes3D
to your imports, your code should work just fine. Here is the full code I used:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
f1 = plt.figure()
ax1 = f1.add_subplot(2, 1, 1, projection=Axes3D.name)
ax1.view_init(20, -120)
plt.show()
This shows:

And to compare it with another view, with ax1.view_init(-120, 20)
for example, it shows:

By the way, a linter might complain about "unused import" Axes3D
, so instead of projection='3d'
I wrote projection=Axes3D.name
in my code above. See How to directly use Axes3D from matplotlib in standard plot to avoid flake8 error for further reading.