How to setup PyCharm like virtual environment for each project

Hello,

I want to setup a kind of system in nvim(NvChad) where whenever I make a new python project, a new virtual environment will be created for it and I run the code, the code will be run within the virtual environment. Now, I tried it through pyright by creating a pyrightconfig.json and using this workon script. Now, I can create a separate virtual environment for each project, but it does not activate the venv of that project when the script is run. Now, I tried modifying the code at the end and changed it to “source .venvPath/bin/activate” but it still does not work. What can I do? Is there a better way to do this? And if possible, is there a way to do it when I use other languages(since i have seen pyright do it, will others do it too?)

Thanks in advance!

Personally, I prefer maintaining my Python venvs in the terminal, and activating them before launching nvim. In this way, every :terminal in the nvim instance will run inside the virtual environment. I’m not sure if it is possible to activate a venv from inside nvim and achieve the same behaviour, but you might have some luck asking nvchad users.

See also: