Replies: 1 comment 5 replies
-
https://github.com/pinkmilk4/batscriptcrazy/blob/main/python_venv/venv.bat Here is the script I have been working on the automate the process ... just for reference |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am having trouble programmatically creating a virtual environment which is external to the workspace and configuring the debugger to use it.
I am working in Windows and have written a bat script called 'venv.bat' that creates a new virtual environment in a folder outside of the current working directory and activates it such that running "python someFile.py" will use the venv interpreter and its dependencies. However, I want to be able to debug my python code and use the virtual environment's interpreter. I noticed that launch.json cannot evaluate the system environment variables my bat script sets.
Assume VIRTUAL_ENV=%USERPROFILE%\venv
In launch.json, I tried to access VIRTUAL_ENV to specify the python interpreter with the configuration below. However this does not work....
{
"name": "Python Debugger: Project1",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/project1/test.py",
"python": "${env:VIRTUAL_ENV}\Scripts\python.exe",
"console": "integratedTerminal",
}
This configuration works but I had to set it manually and the absolute path may change
{
"name": "Python Debugger: Project1",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/project1/test.py",
"python": "${userHome}\venv\Scripts\python.exe",
"console": "integratedTerminal",
}
Therefore ${userHome}\venv\Scripts\python.exe worked but ${env:VIRTUAL_ENV}\Scripts\python.exe did not and this is NOT ok because I only want to express the location of the virtual environment programmatically
I wrote this script for non-software engineers to set up a local python environment on their computes for running data analysis python scripts. They are not familiar with vscode IDE so I tried to create a solution for them as seamless as possible. Ideally they would run my bat script to activate the environment then can click "run and debug" to begin stepping through their python code. I want to avoid using the vscode way of creating the virtual environment because my bat script will take care of creating it, installing the packages, and activating it. The people I wrote this script for should not have to repeat these steps
What should I do? I don't have time to walk 10 engineers through how to use vscode and configure all these different settings manually. Why can't the extension just use the python that is active in the terminal shell? Please help!!!
Beta Was this translation helpful? Give feedback.
All reactions