python - Windows:使用 PostGres 时 Python 子进程“找不到指定的文件”
问题描述
我正在使用包pytest-server-fixtures在 Windows 上使用 PostGres 数据库进行测试。尝试访问 pg_config.exe 时包中出现问题:
subprocess.check_output(["pg_config", "--bindir"])
给出的错误:
The system cannot find the file specified
我知道这是一个相对常见的错误,但没有其他答案解决了这个问题。
我尝试过的事情:
• pg_config.exe 存在于 C:\Program Files\PostgreSQL\11\bin 中,并且已添加到我的 PATH 中。
•pg_config --bindir
在Python 之外运行会返回一个路径。
• 运行check_output
不成功shell=True
。
• 运行check_output
不成功shutil.which('pg_config')
。
• psycopg2 是在 PostGres 安装后安装的。
• 尝试使用 psycopg2-binary 失败。
• 这些测试是在 MacOS 上编写的,并且正在那里和 Linux 上成功运行。
• pg_config.exe 具有读取和执行权限。
任何帮助表示赞赏!谢谢!
解决方案
推荐阅读
- linux - 当目录名称包含空格且目录具有特定文件扩展名时,如何遍历目录并将它们移动到另一个位置
- windows - 对文件夹中的图片进行排序
- jhipster - 如何为基于令牌的身份验证禁用 csrf 并为浏览器启用它?
- php - Wget Linux 命令正在为仅 sudo 用户下载具有读取权限的文件 - 如何为所有用户授予读取权限?
- python - 在 Python 中从给定的长十六进制数中获取 8 位数字
- ios - 在计时器的帮助下,Swift 4 在页面视图控制器中自动滑动
- c++ - 手动执行 C++ 向量
- javascript - Eloquent JS:电子生活项目问题
- embedded - USB CDC:STM32F103RBT6 无法显示 USB 设备
- sql - 在 SQL Server 2016 中按子句排序的单个案例中的多列