我具有subrpocess
函数来启动postgres
表。但是我收到文件路径错误
filepath = self.get_path(filename)
...
if not append:
# Create the new table itself without adding actual data.
print "this is the path {}\n\n".format(filepath)
print "does file exist".format(os.path.isfile(filepath))
create_table = subprocess.Popen(['shp2pgsql', '-p', '-I',
'-s', str(srid),
'-W', encoding,
filepath, table],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
这是我得到的回溯:
this is the path C:/Urbansims/inputs\geographies/cities.shp
does file exist? True
Traceback (most recent call last):
File "loading_data.py", line 117, in <module>
loader.load_shp_map({value["sql_in"]:"/".join(value["input"].rsplit("/",2)[1:]) for key,value in geo_inputs.iteritems()})
File "c:\urbansims\libs\spandex\spandex\io.py", line 416, in load_shp_map
self.load_shp(filename=value, table=table, drop=True)
File "c:\urbansims\libs\spandex\spandex\io.py", line 369, in load_shp
universal_newlines=True)
File "C:\Anaconda2\lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "C:\Anaconda2\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
该路径存在,并且os.find.path返回该位置的True。如果它显然是文件的正确路径,为什么系统找不到该路径?
答案 0 :(得分:1)
您正在使用filepath
作为要在单独过程中启动的shp2pgsql
工具的自变量。错误是由于找不到shp2pgsql
。