Conda创建python虚拟环境(windows系统下)

    技术2025-09-23  42

    Conda创建python虚拟环境(windows系统下)

    虚拟环境就是借助虚拟机docker来把一部分内容独立出来,我们把这部分独立出来的东西称作“容器”,在这个容器中,我们可以只安装我们需要的依赖包,各个容器之间互相隔离,互不影响。

    conda常用命令

    说明命令查看安装了哪些包conda list查看当前存在哪些虚拟环境conda env list更新condaconda update conda激活虚拟环境activate your_env_name

    Conda创建python虚拟环境

    创建虚拟环境 conda create -n your_env_name python=X.X(2.7或3.7等)

    可能出错的情况:

    An unexpected error has occurred. Conda has prepared the above report.If submitted, this report will be used by core maintainers to improve future releases of conda.Would you like conda to send this report to the core maintainers?

    使用conda clean -i ,然后再重新尝试

    同时也可以复制现有环境

    conda create -n your_env_name --clone clone_name 激活虚拟环境 activate your_env_name 对虚拟环境安装包 conda install -n your_env_name package_name 关闭虚拟环境(回到默认环境) deactivate env_name 删除虚拟环境 conda remove -n your_env_name --all 删除虚拟环境中的某个包 conda remove --name $your_env_name $package_name

    pytcharm切换conda虚拟环境,请点这里

    查看conda配置(channels为镜像源) conda config --show 净化包(删除没有使用的包) conda clean -p 删除旧镜像源 conda config --remove channels xxx 换回默认源 conda config --remove-key channels

    jupyter notebook中使用虚拟环境

    在虚拟环境中安装ipykernel conda install ipykernel 生成kernel python -m ipykernel install --name kernel_name 在jupyter notebook中切换即可

    Processed: 0.011, SQL: 10