---> Computing dependencies for python34
---> Fetching archive for python34
---> Attempting to fetch python34-3.4.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/python34
---> Attempting to fetch python34-3.4.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/python34
---> Installing python34 @3.4.1_0
---> Activating python34 @3.4.1_0
To make python 3.4 the default (i.e. the version you get when you run 'python'),
please run:
sudo port select --set python python34
---> Cleaning python34
---> Updating database of binaries
---> Scanning binaries for linking errors
---> No broken files found.
sudo port select --set python python34
Selecting 'python34' for 'python' succeeded. 'python34' is now active.
/opt/local/bin/pythonがpython34にリンクされている。ってことはmacportsでダウンロードしたものは/opt/localにインストールされるのか。
でもpythonというexecutableは/usr/bin/pythonもあってこっちは2.7.7が使われる。これを削除すれば/opt/local/bin/pythonが認識されるようになるか。
とりあえずこれでpython3.4インストールだん。
次にnetcdfなど必要なものをインストール。
sudo port install py34-netcdf4 py34-matplotlib py34-scipy py34-numpy
これで全て必要なものは揃ったはず。試しに昨日python2.7.7で使ったコードを走らせてみたら無事作図された:
# import the netCDF4 module
from netCDF4 import Dataset
# open the netcdf file for reading.
ncfile = Dataset('resolute/resolute.nc','r')
# read the variable named ''
data = ncfile.variables['temp'][:]
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate
# Generate data:
x, y, z = 10 * np.random.random((3,10))
# Set up a regular grid of interpolation points
xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
xi, yi = np.meshgrid(xi, yi)
# Interpolate
rbf = scipy.interpolate.Rbf(x, y, z, function='linear')
zi = rbf(xi, yi)
plt.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower',
extent=[x.min(), x.max(), y.min(), y.max()])
plt.scatter(x, y, c=z)
plt.colorbar()
plt.show()
python初心者なので、せっかくだから2ではなく3を使ってみようと思う。