首页 > 解决方案 > FileNotFoundError: [WinError 3] 系统找不到指定的路径:'MP_Data\\hello'

问题描述

# Path for exported data, numpy arrays
DATA_PATH = os.path.join('MP_Data') 

# Actions that we try to detect
actions = np.array(['hello', 'thanks', 'iloveyou'])

# Thirty videos worth of data
no_sequences = 30

# Videos are going to be 30 frames in length
sequence_length = 30

# Folder start
start_folder = 30

for action in actions: 
    dirmax = np.max(np.array(os.listdir(os.path.join(DATA_PATH, action))).astype(int))
    for sequence in range(1,no_sequences+1):
        try: 
            os.makedirs(os.path.join(DATA_PATH, action, str(dirmax+sequence)))
        except:
            pass

错误:

FileNotFoundError                         Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4900/2191428336.py in <module>
      1 for action in actions:
----> 2     dirmax = np.max(np.array(os.listdir(os.path.join(DATA_PATH, action))).astype(int))
      3     for sequence in range(1,no_sequences+1):
      4         try:
      5             os.makedirs(os.path.join(DATA_PATH, action, str(dirmax+sequence)))

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'MP_Data\\hello'

标签: python

解决方案


得到了答案:

for action in actions: 
    for sequence in range(no_sequences):
        try: 
            os.makedirs(os.path.join(DATA_PATH, action, str(sequence)))
        except:
            pass

推荐阅读