gpt4 book ai didi

python - 子进程系统找不到指定的文件错误

转载 作者:行者123 更新时间:2023-12-01 08:25:46 24 4
gpt4 key购买 nike

我有subrpocess函数启动 postgres table 。但我收到文件路径错误

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。为什么系统找不到该路径,明明是正确的文件路径?

最佳答案

您正在使用filepath作为您尝试在单独进程中启动的shp2pgsql工具的参数。该错误来自于 shp2pgsql 未找到。

关于python - 子进程系统找不到指定的文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54261298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com