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

时间:2016-07-01 23:22:20

标签: python

我想使用mongoimport(Anaconda -Windows平台)导入大量数据。我构建了一个mongoimport命令,我使用subprocess.call来执行。

这是我的代码

 # Build mongoimport command
 collection = cal_data[:cal_data.find(".")]
 #print collection
 working_directory = "/Users/"

 json_file = cal_data + ".json"
 #print json_file
 mongoimport_cmd = "mongoimport --db " + db_name + \
                  " --collection " + collection + \
                  " --file " + working_directory + json_file
 #print mongoimport_cmd 

 # Before importing, drop collection if it exists
  if collection in db.collection_names():
    print ("dropping collection")
    db[collection].drop()

 # Execute the command
 print ("Executing: " + mongoimport_cmd)
 subprocess.call(mongoimport_cmd.split())

这是我得到的错误

执行:mongoimport --db osm --collection chattanooga --file /Users/chattanooga.osm.json

FileNotFoundError Traceback(最近一次调用最后一次)  in()      16#执行命令      17打印(“执行:”+ mongoimport_cmd) ---> 18 subprocess.call(mongoimport_cmd.split())

C:\ Users \ MMedouani \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ subprocess.py in call(timeout,* popenargs,** kwargs)     558 retcode = call([“ls”,“ - l”])     559“”“ - > 560与Popen(* popenargs,** kwargs)作为p:     561尝试:     562返回p.wait(超时=超时)

init 中的

C:\ Users \ MMedouani \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ subprocess.py(self,args,bufsize,executable,stdin,stdout,stderr,preexec_fn,close_fds ,shell,cwd,env,universal_newlines,startupinfo,creationflags,restore_signals,start_new_session,pass_fds)     948 c2pread,c2pwrite,     949 errread,errwrite, - > 950 restore_signals,start_new_session)     951除外:     952#如果孩子开始失败则进行清理。

_execute_child中的

C:\ Users \ MMedouani \ AppData \ Local \ Continuum \ Anaconda3 \ lib \ subprocess.py(self,args,executable,preexec_fn,close_fds,pass_fds,cwd,env,startupinfo,creationflags,shell,p2cread, p2cwrite,c2pread,c2pwrite,errread,errwrite,unused_restore_signals,unused_start_new_session)    1218 env,    1219 cwd, - > 1220 startupinfo)    1221终于:    1222#Child正在推出。关闭那些管道的父副本

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

0 个答案:

没有答案