Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Environment

  • Pythonnet version:3.0.5
  • Python version:3.12
  • Operating System:win11
  • .NET Runtime:.net8

Details

  • Describe what you were trying to get done.

I tested the virtual environment created with Poetry and it always failed. The test found that there were issues with the environment variables

Environment.SetEnvironmentVariable("AA","BB");

Runtime.PythonDLL = @"D:\Program Files\Python312\python312.dll";
PythonEngine.Initialize();

PythonEngine.RunSimpleString("""

                             import os
                             
                             for e in os.environ:
                                 print(e,':', os.environ[e])
                             """);

no AA in os.environ, so Environment variables in https://github.com/pythonnet/pythonnet/wiki/Using-Python.NET-with-Virtual-Environments no effect, So it leads to the inability to call Python in virtual environments?

You must be logged in to vote

Replies: 1 comment

Comment options

I'm also experiencing this, but even environment variables set outside of the runtime seem to have no effect. I also tried setting them with dotnet test -e AA=BB, but even those don't show up in os.environ. Even the explicitly read VIRTUAL_ENV has no effect, which makes me wonder whether this is an issue with .NET itself. I'm using 8.0

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2538 on January 04, 2025 19:32.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.