Django应用中的子流程不会在生产环境中写入文件

问题描述

这里是设置-这是一台Windows 2016 Server,以Apache作为Web服务器。 subprocess调用如下:

subprocess_results = subprocess.run(['pgsql2shp','-f',<path-to-output-shapefile>,'-h','127.0.0.1','-u',<user_name>,'-P',<password>,'database_name','SELECT * FROM temp'],capture_output=True)

当我在开发中运行此文件manage.py runserver)时,shapefile在<path-to-output-shapefile>处创建。但是,如果尝试在Apache生产服务器中运行它,则subprocess_results.returncode返回0,但是没有shapefile写入<path-to-output-shapefile>。我检查了以下内容

  1. postgresql表确实存在。
  2. <path-to-output-shapefile>文件夹权限对SYstemAdministratorsUSERS和我的用户帐户具有“完全控制”权限。
  3. 我已经在管理PowerShell中运行pgsql2shp命令,并且shapefile被创建。

有人可以告诉我我可能做错了什么吗?这是Django设定吗?是我缺少的Apache配置吗?

编辑:

在我所有的SO搜索中,直到发布此问题后,我才能找到this answer。提供pgsql2shp.exe的绝对路径可以解决该问题,并且现在正在创建shapefile。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)