anaconda3轻松解决python环境问题

1 anaconda3简介

Anaconda3是一个用于数据科学和机器学习的Python发行版本,包含了大量的科学包和工具。

Anaconda3还提供了环境管理功能,允许用户在同一台机器上安装和使用多个版本的Python,并且可以轻松切换。

特别是在linux环境,由于python官方只提供了源码安装包,通过源码编译安装可能会出现各种依赖的缺失,安装变得异常麻烦,使用anaconda3能够非常轻松地解决python环境问题。

2 安装anaconda3

本文系统:Ubuntu 20.04.6 LTS

下载安装包:

https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh

安装:

./Anaconda3-2023.09-0-Linux-x86_64.sh  

安装过程:

Welcome to Anaconda3 2023.09-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 
==================================================
End User License Agreement - Anaconda Distribution
==================================================

Copyright 2015-2023, Anaconda, Inc.

All rights reserved under the 3-clause BSD License:
。。。省略。。。
。。。省略。。。
。。。省略。。。
Do you accept the license terms? [yes|no]
[no] >>> yes
Anaconda3 will now be installed into this location:
/root/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/anaconda3] >>>    #直接回车,将安装在/root/anconda3目录下
PREFIX=/root/anaconda3
Unpacking payload ...
                                                                                                                     
Installing base environment...


Downloading and Extracting Packages


Downloading and Extracting Packages

Preparing transaction: done
Executing transaction: \ 

    Installed package of scikit-learn can be accelerated using scikit-learn-intelex.
    More details are available here: https://intel.github.io/scikit-learn-intelex

    For example:

        $ conda install scikit-learn-intelex
        $ python -m sklearnex my_application.py

    
                                                                                                                   done
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>>yes
no change     /root/anaconda3/condabin/conda
no change     /root/anaconda3/bin/conda
no change     /root/anaconda3/bin/conda-env
no change     /root/anaconda3/bin/activate
no change     /root/anaconda3/bin/deactivate
no change     /root/anaconda3/etc/profile.d/conda.sh
no change     /root/anaconda3/etc/fish/conf.d/conda.fish
no change     /root/anaconda3/shell/condabin/Conda.psm1
no change     /root/anaconda3/shell/condabin/conda-hook.ps1
no change     /root/anaconda3/lib/python3.11/site-packages/xontrib/conda.xsh
no change     /root/anaconda3/etc/profile.d/conda.csh
modified      /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

Thank you for installing Anaconda3!

重新开一个窗口登录生效。

(base) root@db01:~# 

安装过程中修改了.bashrc,在文件末尾添加了如下内容:

在这里插入图片描述

2 anaconda3相关操作

2.1 查看环境

conda info –envs
conda info
conda env list

在这里插入图片描述

在这里插入图片描述

2.2 创建环境:

conda create -n milvus python=3.11.7

输出:

## Package Plan ##

  environment location: /root/anaconda3/envs/milvus

  added / updated specs:
    - python=3.11.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2023.12.12 |       h06a4308_0         126 KB
    openssl-3.0.12             |       h7f8727e_0         5.2 MB
    pip-23.3.1                 |  py311h06a4308_0         3.3 MB
    python-3.11.7              |       h955ad1f_0        32.8 MB
    setuptools-68.2.2          |  py311h06a4308_0         1.2 MB
    tzdata-2023d               |       h04d1e81_0         117 KB
    wheel-0.41.2               |  py311h06a4308_0         145 KB
    xz-5.4.5                   |       h5eee18b_0         646 KB
    ------------------------------------------------------------
                                           Total:        43.6 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main 
  _openmp_mutex      pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu 
  bzip2              pkgs/main/linux-64::bzip2-1.0.8-h7b6447c_0 
  ca-certificates    pkgs/main/linux-64::ca-certificates-2023.12.12-h06a4308_0 
  ld_impl_linux-64   pkgs/main/linux-64::ld_impl_linux-64-2.38-h1181459_1 
  libffi             pkgs/main/linux-64::libffi-3.4.4-h6a678d5_0 
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1 
  libgomp            pkgs/main/linux-64::libgomp-11.2.0-h1234567_1 
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1 
  libuuid            pkgs/main/linux-64::libuuid-1.41.5-h5eee18b_0 
  ncurses            pkgs/main/linux-64::ncurses-6.4-h6a678d5_0 
  openssl            pkgs/main/linux-64::openssl-3.0.12-h7f8727e_0 
  pip                pkgs/main/linux-64::pip-23.3.1-py311h06a4308_0 
  python             pkgs/main/linux-64::python-3.11.7-h955ad1f_0 
  readline           pkgs/main/linux-64::readline-8.2-h5eee18b_0 
  setuptools         pkgs/main/linux-64::setuptools-68.2.2-py311h06a4308_0 
  sqlite             pkgs/main/linux-64::sqlite-3.41.2-h5eee18b_0 
  tk                 pkgs/main/linux-64::tk-8.6.12-h1ccaba5_0 
  tzdata             pkgs/main/noarch::tzdata-2023d-h04d1e81_0 
  wheel              pkgs/main/linux-64::wheel-0.41.2-py311h06a4308_0 
  xz                 pkgs/main/linux-64::xz-5.4.5-h5eee18b_0 
  zlib               pkgs/main/linux-64::zlib-1.2.13-h5eee18b_0 


Proceed ([y]/n)?y

2.3 删除环境:

conda env list

在这里插入图片描述

conda remove -n milvus --all

2.4 激活环境:

conda create -n milvus python=3.11.7
conda activate milvus
python --version

在这里插入图片描述

2.5 退出环境:

conda deactivate

3 卸载anaconda3

参考:

https://docs.anaconda.com/free/anaconda/install/uninstall/

conda init --reverse --all

新开一个窗口:

删除安装目录,例如: rm -rf /root/ anaconda3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shulu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值