I have many python projects. Each runs in a virtual environment, which allows me to have different interpreters for each project. In addition, each virtual environment has its own set of extensions. For example, my current project uses PyQt. These extensions are installed into the virtual environment using pip. The virtual environment is stored in a .venv file at the root of the project. But none of the python extensions seem to recognize my virtual environment.
Is there a way to make Nova understand the virtual environment for each project?
The latest version of my Python extension (Python | Nova Extensions) included support for scanning for a .venv directory at the project root. This doesn’t happen automatically though, you need to select it in the Python extension settings for your project. You can also set your venv as the built-in interpreter (i.e. for the Python extension included with Nova) if you’re using any of the built-in python tasks.
I’m not really sure I understand - what is a “remote project”? I suspect the answer is this only works locally, because virtual environments only work locally - unless you have some kind of file sharing setup and the remote server is similar enough to your own machine that running a python binary from it works on your computer.
Is there any additional configuration needed for this to work? I think I must be missing a step — the “Virtual Environment” task reports “the file doesn’t exist”, though I selected it from the task configuration modal window. The extension sidebar does correctly report the installed packages so I’m confident that part is working correctly.
This is not well-communicated, but executing a script expects two things:
It should start with #!/usr/bin/env python
It needs to be executable (chmod +x test_script.py)
Alternatively, you could simply enter test_scrtipt as the module to run instead, which is the equivalent of saying python -m test_script with the virtualenv activated.