How to setup CSnakes to use existing Virtual Python env and Conda env (on Windows Server) #545
-
Hi, Using a virtual Python env (created via python.exe -m venv C:\Temp\PythonVirtualEnv/v312/csnakes_env):
Which is expected because this is a virtual env. Maybe I’m passing wrong argument or something Using an existing Conda env:
It produces below error: Sorry if this is a dumb question but I can't make it work. I'm missing something, i'm sure It works fine with new python env that is downloaded from NuGet, or with existing python env (but not virtual env) Also 2 more question regarding env:
Any reply will be much appreciated. Thanks a lot |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Ok, a few things to unpack here,
Second, Set that to false:
|
Beta Was this translation helpful? Give feedback.
-
You can reload a module, every source generated module has a If you're finding the environment creation slow with the pip installer, try the uv installer.
The reason this is practically very difficult/impossible is because Python doesn't support multiple runtimes in the same process. Just the same as you can't load two versions of the same .NET assembly into the same process. If it's concurrency you're after, we do support async (although not truly concurrent) functions. Most IO activities in Python actually release the GIL and so async is often a good solution. We also support the experimental free-threaded Python builds, where the GIL is removed altogether. For those you could freely use them in Task pools or use something like parallel LINQ. |
Beta Was this translation helpful? Give feedback.
Ok, a few things to unpack here,
.FromFolder(virtual_python_env, "3.12")
is for specialized Python builds on Windows and probably not what you want. If you downloaded Python from python.org, you want theWindows Installer Locator
If you installed it from the Windows Store, you want the
Windows Store Locator
.Second,
.WithVirtualEnvironment()
has a second parameter to set whether or not to "ensure the virtual environment exists" (create it).Set that to false:
.WithVirtualEnvironment(virtual_python_env, false)