I am trying to run some pytests on vscode in a conda environment. The connection to my postgres db is handled by flask/flask-sqlalchemy and I have installed the add-ons for pytest (pytest-flask, pytest-postgresql), to use some fixtures.
When I'm now trying to run a test (or all of them), I get the following error message:
FileNotFoundError: [Errno 2] No such file or directory: '/home/robert/software/anaconda3/envs/python38/bin/pg_ctl'
Now, this is somewhat obvious because the conda env indeed does not have a pg_ctl module. It is rather the (system-wide) installation of postgres, that has it. I tried to modify PATH
, including the path to the pg_ctl module via the .profile
config file, but:
!! once I execute the run command in vscode, some process either triggered by the vscode testing extension or conda (or both?!?!) modifies the PATH envvar so that the error occurs.
When I run pytest .
in the terminal, the test runs fine.
When I run "Debug Test" the test runs fine.
Anybody any clue??
Setup: vscode 1.65, conda 4.9.2, python 3.8
I'll try to provide an MVE once I find out how to reproduce it...
CodePudding user response:
Could you add this to your settings.json file?
"terminal.integrated.env.osx": { "PYTHONPATH": "{the path of pg_ctl folder}" },
When terminal settings are used, PYTHONPATH can affect any tools that are run within the terminal.
You can refer to the official docs for more details.