Running a python script as headless without pvpython/pvbatch

I’m working on a Paraview project that runs as a Python script. It’s crashing when I try using it in a CAVE and I believe it’s because of the VTK Render window it’s opening whenever it runs. I want to stop this window from opening and I’ve seen this can be done by running the script in headless mode with --force-offscreen-rendering in pvpython or with pvbatch. The problem is I have packages that I need to include that pvpython doesn’t have:
mcp[cli]>=1.10.0,<2.0.0
httpx>=0.24.0
Pillow>=9.0.0
fastmcp
I’ve been creating a virtual environment, pip installing said packages, and then copy pasting the files from site-packages in paraview to the site-packages in the venv. This has been working fine for my uses except I can’t figure out how to run my script as headless with this setup.

I’ve seen other people using venvs with pvpython but it hasn’t worked for me. I get errors like this.

>> import mcp

Traceback (most recent call last): File “”, line 1, in File “C:\Users\raw17\paraview_mcp\venvs\paraview_mcp_test2\Lib\site-packages\mcp_init_.py”, line 1, in from .client.session import ClientSession File “C:\Users\raw17\paraview_mcp\venvs\paraview_mcp_test2\Lib\site-packages\mcp\client\session.py”, line 6, in import anyio.lowlevel File “C:\Users\raw17\paraview_mcp\venvs\paraview_mcp_test2\Lib\site-packages\anyio_init_.py”, line 35, in from ._core._sockets import TCPConnectable as TCPConnectable File “C:\Users\raw17\paraview_mcp\venvs\paraview_mcp_test2\Lib\site-packages\anyio_core_sockets.py”, line 6, in import ssl File “C:\t\ParaView-6.0.1-MPI-Windows-Python3.12-msvc2017-AMD64\bin\Lib\ssl.py”, line 100, in import _ssl # if we can’t import it, let the error propagate ^^^^^^^^^^^ ModuleNotFoundError: No module named ‘_ssl’

Is there anyway to run my python script as headless? I really don’t want to have to compile my own version.

(Windows, 6.0.1 MPI version) (I also tried copying _ssl.pyd into the bin directory and that didn’t work)