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

WSL中Conda环境无法隔离,可导入非当前环境包的问题求助

WSL中Conda环境无法隔离,可导入非当前环境包的问题求助

我最近在Windows Subsystem for Linux(WSL)上装了conda,结果遇到个头疼的问题:创建新的conda环境后,不管是在终端直接跑Python,还是在VS Code里打开Jupyter Notebook,居然都能导入当前环境里根本没有的包。

我操作的步骤是这样的:

conda create -n myenv python=3.10.9 --no-default-packages
conda activate goldrush
conda list

conda list的输出是符合预期的,里面确实没有numpy、matplotlib这类包:

# packages in environment at /home/csa/anaconda3/envs/goldrush:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
asttokens                 3.0.0              pyhd8ed1ab_1    conda-forge
bzip2                     1.0.8                h4bc722e_7    conda-forge
ca-certificates           2025.1.31            hbcca054_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_1    conda-forge
debugpy                   1.8.12          py310hf71b8c6_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_1    conda-forge
exceptiongroup            1.2.2              pyhd8ed1ab_1    conda-forge
executing                 2.1.0              pyhd8ed1ab_1    conda-forge
importlib-metadata        8.6.1              pyha770c72_0    conda-forge
ipykernel                 6.29.5             pyh3099207_0    conda-forge
ipython                   8.32.0             pyh907856f_0    conda-forge
jedi                      0.19.2             pyhd8ed1ab_1    conda-forge
jupyter_client            8.6.3              pyhd8ed1ab_1    conda-forge
jupyter_core              5.7.2              pyh31011fe_1    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.21.3               h659f571_0    conda-forge
ld_impl_linux-64          2.43                 h712a8e2_2    conda-forge
libedit                   3.1.20240808    pl5321h7949ede_0    conda-forge
libffi                    3.4.4                h6a678d5_1
libgcc                    14.2.0               h77fa898_1    conda-forge
libgcc-ng                 14.2.0               h69a702a_1    conda-forge
libgomp                   14.2.0               h77fa898_1    conda-forge
liblzma                   5.6.3                hb9d3cd8_1    conda-forge
liblzma-devel             5.6.3                hb9d3cd8_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libsodium                 1.0.20               h4ab18f5_0    conda-forge
libsqlite                 3.48.0               hee588c1_1    conda-forge
libstdcxx                 14.2.0               hc0a3c3a_1    conda-forge
libstdcxx-ng              14.2.0               h4852527_1    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libzlib                   1.3.1                hb9d3cd8_2    conda-forge
matplotlib-inline         0.1.7              pyhd8ed1ab_1    conda-forge
ncurses                   6.5                  h2d0b736_3    conda-forge
nest-asyncio              1.6.0              pyhd8ed1ab_1    conda-forge
openssl                   3.4.0                h7b32b05_1    conda-forge
packaging                 24.2               pyhd8ed1ab_2    conda-forge
parso                     0.8.4              pyhd8ed1ab_1    conda-forge
pexpect                   4.9.0              pyhd8ed1ab_1    conda-forge
pickleshare               0.7.5           pyhd8ed1ab_1004    conda-forge
pip                       25.0               pyh8b19718_0    conda-forge
platformdirs              4.3.6              pyhd8ed1ab_1    conda-forge
prompt-toolkit            3.0.50             pyha770c72_0    conda-forge
psutil                    6.1.1           py310ha75aee5_0    conda-forge
ptyprocess                0.7.0              pyhd8ed1ab_1    conda-forge
pure_eval                 0.2.3              pyhd8ed1ab_1    conda-forge
pygments                  2.19.1             pyhd8ed1ab_0    conda-forge
python                    3.10.16         he725a3c_1_cpython    conda-forge
python-dateutil           2.9.0.post0        pyhff2d567_1    conda-forge
python_abi                3.10                    5_cp310    conda-forge
pyzmq                     26.2.1          py310h71f11fc_0    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                75.8.0             pyhff2d567_0    conda-forge
six                       1.17.0             pyhd8ed1ab_0    conda-forge
sqlite                    3.48.0               h9eae976_1    conda-forge
stack_data                0.6.3              pyhd8ed1ab_1    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
tornado                   6.4.2           py310ha75aee5_0    conda-forge
traitlets                 5.14.3             pyhd8ed1ab_1    conda-forge
typing_extensions         4.12.2             pyha770c72_1    conda-forge
tzdata                    2025a                h78e105d_0    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_1    conda-forge
wheel                     0.45.1             pyhd8ed1ab_1    conda-forge
xz                        5.6.3                hbcc6ac9_1    conda-forge
xz-gpl-tools              5.6.3                hbcc6ac9_1    conda-forge
xz-tools                  5.6.3                hb9d3cd8_1    conda-forge
zeromq                    4.3.5                h3b0a872_7    conda-forge
zipp                      3.21.0             pyhd8ed1ab_1    conda-forge
zlib                      1.3.1                hb9d3cd8_2    conda-forge

可当我执行下面的命令打开Notebook:

code mycode.ipynb

并且已经选中myenv环境(VS Code右上角的提示明确显示我在这个环境下运行Python),却能轻松导入那些不在当前环境里的包。我现在需要一个有特定版本依赖的环境来运行某个关键程序,这种环境隔离失效的情况会导致Python自动切回base环境,完全没法满足需求。到底是哪里出问题了?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.14 08:28:04