最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Unable to create "clean" conda environment - Stack Overflow

programmeradmin0浏览0评论

I've recently installed conda on Windows Subsystem for Linux. When I create a new conda environment and either run Python in the terminal or open a Jupyter notebook in VScode, I'm able to import packages that don't exist in this environment.

Here's all that I've done:

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

This conda list command gives the expected output:

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

no numpy, no matplotlib, etc. However, when I do

code mycode.ipynb

and select the myenv environment (I have the little message in the top right of my VScode window telling me I am, indeed, running Python in myenv), I'm able to import those packages with no problem. I need to create an environment with particular versions of packages for one critical package to run, and for that to work, I can't have Python reverting to the base environment every time I run the import command. What am I doing wrong?

发布评论

评论列表(0)

  1. 暂无评论