You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python.NET无法使用虚拟环境问题求助

Python.NET无法使用虚拟环境问题求助

我照着Python.NET虚拟环境的相关使用指南操作,但怎么都没法让Python.NET用上我创建好的虚拟环境,实在搞不定来求助!

我写了个简单的测试流程:先初始化Python.NET,运行一个能列出当前已安装Python包的脚本;接着配置好对应路径和环境变量,切换到预先创建的虚拟环境,再重新运行同一个脚本。结果两次输出的包列表完全一模一样,根本没切换到虚拟环境里的包。

附上我用到的代码:

listpip.py

from importlib import metadata

def go():
    for dist in metadata.distributions():
        print(f"{dist.name}=={dist.version}")

program.cs

namespace PythonLoader
{
    using System;
    using System.Runtime.InteropServices;
    using Python.Runtime;

    public class ProgramPipList
    {
        public static void Main(string[] ...

备注:内容来源于stack exchange,提问作者joelc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 11:05:30