Visual Studio Code virtual environment manager for Python.
vsvenv is a zsh library that contains functions to easen virtual environment setup and usage in VSCode using the built-in python venv package. Because of this, vsvenv only works for python versions 3.3 and above.
For now, you can go to vsvenv.zsh and copy all of the code written there. Then direct to your terminal and make sure you're using z-shell.
Once at the home directory, type in: nano ~/.zshrc
and a text-editor should pop up. Paste the copied code at the bottom of the file. Then write out the file with ctrl+o
enter
ctrl+x
. Your .zshrc
will now be updated with all of the functionality needed to run vsvenv.
To create a new venv, cd into your desired project directory and type in: vsvenv <python-version> [-d "<directory>"]
.
If the -d
flag is not provided, the program will default to use ./env
for the venv. In the case that the selected directory already exists, you will be prompted to replace it with the venv.
After the venv is created, a settings.json
file will be created under ./.vscode
if it does not already exist. The entry: "python.pythonPath": "env/bin/python"
will be added to the json to link your new venv to the python interpreter in VSCode.
You should now be ready to run your python project directly in VSCode using the venv.