I am trying to set up a (1)Powershell script
that will activate a Python virtual environment with a (2)Python .exe
file to call a (3)Python script
that requires an (4)SQL query
. I want the paths to be relative.
The following script is supposed to do that :
$pythonScript = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath "..python") -ChildPath "script_python.py"
$pythonVenv = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath "..pythonvenvScripts") -ChildPath "python.exe"
$pythonStart = & $pythonVenv $pythonScript
$pythonStart
When working on my (3)Python
script, I can just refer to the SQL query by name without specifying a path, as the working directory is implied to be their python
parent.
However, when calling the script from my PowerShell script, the working directory becomes the Scripts
directory, parents of the virtual environment python.exe
file ; thus, the (4)sql_query.sql
is not found when my Python script is executing.
How can I keep the working directory to be python
just like when I am developping my Python script?