2016-03-24 11 views
0

チュートリアルから次のコードを実行しようとしていますが、エラーが発生します。他の投稿に基づいて、これはアクセス許可の問題(?)のようです。私はchmod 777ソリューションについて読んだことがありますが、それをどのように正確に実装するかはわかりません。私はMacで作業していて、Rodeo Python IDEで次のコードを実行しています。IOError:[Errno 13]権限が拒否されました:修正方法?

def load_dataset(): 
    url = 'http://deeplearning.net/data/mnist/mnist.pkl.gz' 
    filename = 'mnist.pkl.gz' 
    if not os.path.exists(filename): 
     print("Downloading MNIST dataset...") 
     urlretrieve(url, filename) 
    with gzip.open(filename, 'rb') as f: 
     data = pickle.load(f) 
    X_train, y_train = data[0] 
    X_val, y_val = data[1] 
    X_test, y_test = data[2] 
    X_train = X_train.reshape((-1, 1, 28, 28)) 
    X_val = X_val.reshape((-1, 1, 28, 28)) 
    X_test = X_test.reshape((-1, 1, 28, 28)) 
    y_train = y_train.astype(np.uint8) 
    y_val = y_val.astype(np.uint8) 
    y_test = y_test.astype(np.uint8) 
    return X_train, y_train, X_val, y_val, X_test, y_test 

X_train, y_train, X_val, y_val, X_test, y_test = load_dataset() 

>>> X_train, y_train, X_val, y_val, X_test, y_test = load_dataset() 
Downloading MNIST dataset... 

--------------------------------------------------------------------------- 
IOError         Traceback (most recent call last) 
<ipython-input-55-b5dfc0ed9477> in <module>() 
----> 1 X_train, y_train, X_val, y_val, X_test, y_test = load_dataset() 

<ipython-input-51-554e12c9ff6c> in load_dataset() 
     4  if not os.path.exists(filename): 
     5   print("Downloading MNIST dataset...") 
----> 6   urlretrieve(url, filename) 
     7  with gzip.open(filename, 'rb') as f: 
     8   data = pickle.load(f) 

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc in urlretrieve(url, filename, reporthook, data, context) 
    96  else: 
    97   opener = _urlopener 
---> 98  return opener.retrieve(url, filename, reporthook, data) 
    99 def urlcleanup(): 
    100  if _urlopener: 

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc in retrieve(self, url, filename, reporthook, data) 
    247    headers = fp.info() 
    248    if filename: 
--> 249     tfp = open(filename, 'wb') 
    250    else: 
    251     import tempfile 

IOError: [Errno 13] Permission denied: 'mnist.pkl.gz' 

## I'm guessing this means I'm in the root directory. 
>>> print os.getcwd() 
/
+0

[関連](http://meta.stackoverflow.com/questions/318885/fixing-answers-that-recommend-chmod-777) – miradulo

+2

エラー情報を追加できますか? –

+0

絶対パスを使用して、アクセスするファイルを100%確実に確認し、問題のディレクトリのフルエラートレースバックと長い形式のリストを投稿する必要があります。 –

答えて

1

あなたのルート(/)ディレクトリにファイルを保存しようとしている、あなたは、おそらくそこに権限を持っていないように見えます。他の場所に保存してください。

関連する問題