Jupiter Notebookに関してエラーが出たのでそれに関しての質問です。
文章は
original_dataset_dir = '/Users/fchollet/Downloads/kaggle_original_data'
base_dir = '/Users/fchollet/Downloads/cats_and_dogs_small'
os.makedirs(base_dir)
train_dir = os.path.join(base_dir, 'train')
os.makedirs(train_dir)
validation_dir = os.path.join(base_dir, 'validation')
os.makedirs(validation_dir)
test_dir = os.path.join(base_dir, 'test')
os.makedirs(test_dir)
train_cats_dir = os.path.join(train_dir, 'cats')
os.makedirs(train_cats_dir)
train_dogs_dir = os.path.join(train_dir, 'dogs')
os.makedirs(train_dogs_dir)
validation_cats_dir = os.path.join(validation_dir, 'cats')
os.makedirs(validation_cats_dir)
validation_dogs_dir = os.path.join(validation_dir, 'dogs')
os.makedirs(validation_dogs_dir)
test_cats_dir = os.path.join(test_dir, 'cats')
os.makedirs(test_cats_dir)
test_dogs_dir = os.path.join(test_dir, 'dogs')
os.makedirs(test_dogs_dir)
fnames = ['cat.{}.jpg'.format(i) for i in range(1000)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(train_cats_dir, fname)
shutil.copyfile(src, dst)
fnames = ['cat.{}.jpg'.format(i) for i in range(1000, 1500)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(validation_cats_dir, fname)
shutil.copyfile(src, dst)
fnames = ['cat.{}.jpg'.format(i) for i in range(1500, 2000)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(test_cats_dir, fname)
shutil.copyfile(src, dst)
fnames = ['dog.{}.jpg'.format(i) for i in range(1000)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(train_dogs_dir, fname)
shutil.copyfile(src, dst)
fnames = ['dog.{}.jpg'.format(i) for i in range(1000, 1500)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(validation_dogs_dir, fname)
shutil.copyfile(src, dst)
fnames = ['dog.{}.jpg'.format(i) for i in range(1500, 2000)]
for fname in fnames:
src = os.path.join(original_dataset_dir, fname)
dst = os.path.join(test_dogs_dir, fname)
shutil.copyfile(src, dst)
です。
その結果、
PermissionError Traceback (most recent call last)
<ipython-input-19-1c79606d6913> in <module>
6 # store our smaller dataset
7 base_dir = '/Users/fchollet/Downloads/cats_and_dogs_small'
----> 8 os.makedirs(base_dir)
9
10 # Directories for our training,
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
209 if head and tail and not path.exists(head):
210 try:
--> 211 makedirs(head, exist_ok=exist_ok)
212 except FileExistsError:
213 # Defeats race condition when another thread created the path
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
209 if head and tail and not path.exists(head):
210 try:
--> 211 makedirs(head, exist_ok=exist_ok)
212 except FileExistsError:
213 # Defeats race condition when another thread created the path
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
219 return
220 try:
--> 221 mkdir(name, mode)
222 except OSError:
223 # Cannot rely on checking for EEXIST, since the operating system
PermissionError: [WinError 5] アクセスが拒否されました。: '/Users/fchollet'
というエラーが表示されました。
また、このエラーが出る前は
FileNotFoundError Traceback (most recent call last)
<ipython-input-20-d6019ae0df10> in <module>
6 # store our smaller dataset
7 base_dir = '/Users/fchollet/Downloads/cats_and_dogs_small'
----> 8 os.mkdir(base_dir)
9
10 # Directories for our training,
FileNotFoundError: [WinError 3] 指定されたパスが見つかりません。: '/Users/fchollet/Downloads/cats_and_dogs_small'
というエラーが出ていたので一度mkdirからmakedirsに文章を変えています。
エラーの解消法がわからないのでどなたか教えてくださるとうれしいです。
あなたの回答
tips
プレビュー