WinError 2系统找不到指定的文件

时间:2019-06-25 00:59:12

标签: python

我想从https://github.com/intel-isl/Open3D-PointNet2-Semantic3D在Windows 10上从此代码运行文件preprocess.py,原始代码在ubuntu上。

import os
import subprocess
import shutil
import open3d

from dataset.semantic_dataset import all_file_prefixes


def wc(file_name):
    out = subprocess.Popen(
        ["wc", "-l", file_name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
    ).communicate()[0]
    return int(out.partition(b" ")[0])


def prepend_line(file_name, line):
    with open(file_name, "r+") as f:
        content = f.read()
        f.seek(0, 0)
        f.write(line.rstrip("\r\n") + "\n" + content)


def point_cloud_txt_to_pcd(raw_dir, file_prefix):
    # File names
    txt_file = os.path.join(raw_dir, file_prefix + ".txt")
    pts_file = os.path.join(raw_dir, file_prefix + ".pts")
    pcd_file = os.path.join(raw_dir, file_prefix + ".pcd")

    # Skip if already done
    if os.path.isfile(pcd_file):
        print("pcd {} exists, skipped".format(pcd_file))
        return

    # .txt to .pts
    # We could just prepend the line count, however, there are some intensity value
    # which are non-integers.
    print("[txt->pts]")
    print("txt: {}".format(txt_file))
    print("pts: {}".format(pts_file))

    with open(txt_file, "r") as txt_f, open(pts_file, "w") as pts_f:
        for line in txt_f:
            # x, y, z, i, r, g, b
            tokens = line.split()
            tokens[3] = str(int(float(tokens[3])))
            line = " ".join(tokens)
            pts_f.write(line + "\n")

    prepend_line(pts_file, str(wc(txt_file)))

    # .pts -> .pcd
    print("[pts->pcd]")
    print("pts: {}".format(pts_file))

    print("pcd: {}".format(pcd_file))

    point_cloud = open3d.read_point_cloud(pts_file)

    open3d.write_point_cloud(pcd_file, point_cloud)
    os.remove(pts_file)


if __name__ == "__main__":
    # By default
    # raw data: "dataset/semantic_raw"
    current_dir = os.path.dirname(os.path.realpath(__file__))
    dataset_dir = os.path.join(current_dir, "dataset")
    raw_dir = os.path.join(dataset_dir, "semantic_raw")

    for file_prefix in all_file_prefixes:
        point_cloud_txt_to_pcd(raw_dir, file_prefix)

这是错误:

  

文件“”,第1行,在       runfile('D:/Open3D-PointNet2-Semantic3D-master/preprocess.py',wdir ='D:/ Open3D-PointNet2-Semantic3D-master')

     

文件“ C:\ Users \ SAGHO \ anaconda3 \ envs \ py36_gpu \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py”,行786,在运行文件中       execfile(文件名,命名空间)

     

exec文件中的第110行“ C:\ Users \ SAGHO \ anaconda3 \ envs \ py36_gpu \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py”       exec(compile(f.read(),文件名,'exec'),命名空间)

     

文件“ D:/Open3D-PointNet2-Semantic3D-master/preprocess.py”,第70行,在       point_cloud_txt_to_pcd(raw_dir,file_prefix)

     

文件“ D:/Open3D-PointNet2-Semantic3D-master/preprocess.py”,第48行,位于point_cloud_txt_to_pcd中       prepend_line(pts_file,str(wc(txt_file)))

     

文件“ D:/Open3D-PointNet2-Semantic3D-master/preprocess.py”,第11行,在wc中       [“ wc”,“-l”,文件名],stdout = subprocess.PIPE,stderr = subprocess.STDOUT

     

第143行, init 中的文件“ C:\ Users \ SAGHO \ anaconda3 \ envs \ py36_gpu \ lib \ site-packages \ spyder_kernels \ customize \ spydercustomize.py”       super(SubprocessPopen,self)。初始化(* args,** kwargs)

     

文件“ C:\ Users \ SAGHO \ anaconda3 \ envs \ py36_gpu \ lib \ subprocess.py”,第729行, init       restore_signals,start_new_session)

     

文件“ C:\ Users \ SAGHO \ anaconda3 \ envs \ py36_gpu \ lib \ subprocess.py”,行1017,在_execute_child中       startupinfo)

     

FileNotFoundError:[WinError 2]系统找不到指定的文件

0 个答案:

没有答案