当前位置: 首页 > news >正文

How to use conda in Ubuntu 22.04

How to use conda in Ubuntu 22.04

  • 切换清华源
  • 创建环境
  • 查看环境
  • 激活环境
  • 查看环境中的包
  • 在环境中安装包
  • 退出当前环境
  • 命令行自动补全

切换清华源

sudo tee ~/.condarc <<-'EOF'
auto_activate_base: falsechannels:- defaults
show_channel_urls: true
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmsys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudbioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmenpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudsimpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/clouddeepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
EOF

创建环境

lwk@qwfys:~$ conda create -n harbin
Collecting package metadata (current_repodata.json): done
Solving environment: done## Package Plan ##environment location: /home/lwk/anaconda3/envs/harbinProceed ([y]/n)? yPreparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate harbin
#
# To deactivate an active environment, use
#
#     $ conda deactivatelwk@qwfys:~$

查看环境

lwk@qwfys:~$ conda info --envs
# conda environments:
#
base                     /home/lwk/anaconda3
harbin                   /home/lwk/anaconda3/envs/harbin
shaoxing                 /home/lwk/anaconda3/envs/shaoxinglwk@qwfys:~$

激活环境

lwk@qwfys:~$ conda activate harbin
(harbin) lwk@qwfys:~$

查看环境中的包

(harbin) lwk@qwfys:~$ conda list
# packages in environment at /home/lwk/anaconda3/envs/harbin:
#
# Name                    Version                   Build  Channel
(harbin) lwk@qwfys:~$
(harbin) lwk@qwfys:~$ pip list
Package                   Version
------------------------- ----------------
anyio                     4.2.0
apt-clone                 0.2.1
apturl                    0.5.2
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.3.0
asttokens                 2.4.1
async-lru                 2.0.4
async-timeout             4.0.1
attrs                     23.2.0
Babel                     2.14.0
beautifulsoup4            4.10.0
bleach                    6.1.0
blinker                   1.4
Brlapi                    0.8.3
Brotli                    1.0.9
certifi                   2020.6.20
cffi                      1.16.0
chardet                   4.0.0
charset-normalizer        3.3.2
click                     8.0.3
colorama                  0.4.4
comm                      0.2.1
command-not-found         0.3
configobj                 5.0.6
cryptography              3.4.8
cupshelpers               1.0
dbus-python               1.2.18
debugpy                   1.8.0
decorator                 5.1.1
defer                     1.0.6
defusedxml                0.7.1
distro                    1.7.0
exceptiongroup            1.2.0
executing                 2.0.1
eyeD3                     0.8.10
fastjsonschema            2.19.1
filelock                  3.6.0
fqdn                      1.5.1
httplib2                  0.20.2
idna                      3.3
ifaddr                    0.1.7
IMDbPY                    2021.4.18
importlib-metadata        4.6.4
inflection                0.5.1
ipykernel                 6.29.0
ipython                   8.20.0
isoduration               20.11.0
jedi                      0.19.1
jeepney                   0.7.1
Jinja2                    3.1.3
json5                     0.9.14
jsonpointer               2.4
jsonschema                4.21.1
jsonschema-specifications 2023.12.1
jupyter_client            8.6.0
jupyter_core              5.7.1
jupyter-events            0.9.0
jupyter-lsp               2.2.2
jupyter_server            2.12.5
jupyter_server_terminals  0.5.2
jupyterlab                4.0.11
jupyterlab_pygments       0.3.0
jupyterlab_server         2.25.2
keyring                   23.5.0
launchpadlib              1.10.16
lazr.restfulclient        0.14.4
lazr.uri                  1.0.6
louis                     3.20.0
macaroonbakery            1.3.1
Mako                      1.1.3
MarkupSafe                2.0.1
matplotlib-inline         0.1.6
mistune                   3.0.2
more-itertools            8.10.0
mutagen                   1.45.1
nbclient                  0.9.0
nbconvert                 7.14.2
nbformat                  5.9.2
nemo-emblems              6.0.1
nest-asyncio              1.6.0
netaddr                   0.8.0
netifaces                 0.11.0
notebook_shim             0.2.3
oauthlib                  3.2.0
onboard                   1.4.1
openapi                   1.1.0
overrides                 7.7.0
packaging                 21.3
PAM                       0.4.2
pandocfilters             1.5.1
parso                     0.8.3
pexpect                   4.8.0
Pillow                    9.0.1
pip                       22.0.2
platformdirs              4.1.0
prometheus-client         0.19.0
prompt-toolkit            3.0.43
protobuf                  3.12.4
psutil                    5.9.0
ptyprocess                0.7.0
pure-eval                 0.2.2
pycairo                   1.20.1
pycparser                 2.21
pycryptodomex             3.11.0
pycups                    2.0.1
pycurl                    7.44.1
pyelftools                0.27
Pygments                  2.17.2
PyGObject                 3.42.1
PyICU                     2.8.1
pyinotify                 0.9.6
PyJWT                     2.3.0
pymacaroons               0.13.0
PyNaCl                    1.5.0
pyparsing                 2.4.7
pyparted                  3.11.7
pyRFC3339                 1.1
python-apt                2.4.0+ubuntu3
python-dateutil           2.8.2
python-debian             0.1.43+ubuntu1.1
python-gnupg              0.4.8
python-json-logger        2.0.7
python-magic              0.4.24
python-xlib               0.29
pytz                      2022.1
pyxdg                     0.27
PyYAML                    5.4.1
pyzmq                     25.1.2
qrcode                    7.3.1
referencing               0.33.0
reportlab                 3.6.8
requests                  2.31.0
requests-file             1.5.1
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.17.1
screen-resolution-extra   0.0.0
SecretStorage             3.3.1
Send2Trash                1.8.2
setproctitle              1.2.2
setuptools                59.6.0
six                       1.16.0
sniffio                   1.3.0
soupsieve                 2.3.1
stack-data                0.6.3
systemd-python            234
terminado                 0.18.0
tinycss2                  1.1.1
tldextract                3.1.2
tomli                     2.0.1
tornado                   6.4
traitlets                 5.14.1
types-python-dateutil     2.8.19.20240106
typing_extensions         4.9.0
ubuntu-drivers-common     0.0.0
ufw                       0.36.1
Unidecode                 1.3.3
uri-template              1.3.0
urllib3                   1.26.5
vboxapi                   1.0
wadllib                   1.3.6
wcwidth                   0.2.13
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.7.0
websockets                9.1
wheel                     0.37.1
xdg                       5
xkit                      0.0.0
xlrd                      1.2.0
yt-dlp                    2022.4.8
zipp                      1.0.0
(harbin) lwk@qwfys:~$

在环境中安装包

(harbin) lwk@qwfys:~$ conda install openpyxl                                                                                                                                                  
Collecting package metadata (current_repodata.json): done                                                                                                                                     
Solving environment: done                                                                                                                                                                     ## Package Plan ##                                                                                                                                                                            environment location: /home/lwk/anaconda3/envs/harbin                                                                                                                                       added / updated specs:                                                                                                                                                                      - openpyxl                                                                                                                                                                                The following packages will be downloaded:                                                                                                                                                    package                    |            build                                                                                                                                             ---------------------------|-----------------                                                                                                                                             et_xmlfile-1.1.0           |  py312h06a4308_1          12 KB  defaultsopenpyxl-3.0.10            |  py312h5eee18b_0         647 KB  defaultspandas-2.1.4               |  py312h526ad5a_0        14.7 MB  defaults------------------------------------------------------------Total:        15.3 MBThe following NEW packages will be INSTALLED:et_xmlfile         anaconda/pkgs/main/linux-64::et_xmlfile-1.1.0-py312h06a4308_1 openpyxl           anaconda/pkgs/main/linux-64::openpyxl-3.0.10-py312h5eee18b_0 The following packages will be DOWNGRADED:pandas                              2.2.1-py312h526ad5a_0 --> 2.1.4-py312h526ad5a_0 Proceed ([y]/n)? yDownloading and Extracting PackagesPreparing transaction: done                                                                                                                                                                   
Verifying transaction: done                                                                                                                                                                   
Executing transaction: done
(harbin) lwk@qwfys:~$

退出当前环境

(harbin) lwk@qwfys:~$ conda deactivate
lwk@qwfys:~$

命令行自动补全

conda install -c conda-forge conda-bash-completion

具体安装过程如下:

lwk@qwfys:~$ conda install -c conda-forge conda-bash-completion
Channels:- conda-forge- defaults- https://repo.anaconda.com/pkgs/main
Platform: linux-64
Collecting package metadata (repodata.json): \done
Solving environment: done## Package Plan ##environment location: /home/lwk/miniconda3added / updated specs:- conda-bash-completionThe following packages will be downloaded:package                    |            build---------------------------|-----------------_libgcc_mutex-0.1          |      conda_forge           3 KB  conda-forge_openmp_mutex-4.5          |            2_gnu          23 KB  conda-forgebash-completion-2.11       |       ha770c72_1         205 KB  conda-forgeca-certificates-2024.2.2   |       hbcca054_0         152 KB  conda-forgecertifi-2024.2.2           |     pyhd8ed1ab_0         157 KB  conda-forgeconda-24.1.2               |  py312h7900ff3_0         1.2 MB  conda-forgeconda-bash-completion-1.7  |       ha770c72_1          21 KB  conda-forgelibexpat-2.5.0             |       hcb278e6_1          76 KB  conda-forgelibgcc-ng-13.2.0           |       h807b86a_5         752 KB  conda-forgelibgomp-13.2.0             |       h807b86a_5         410 KB  conda-forgelibnsl-2.0.1               |       hd590300_0          33 KB  conda-forgelibsqlite-3.45.1           |       h2797004_0         839 KB  conda-forgelibuuid-2.38.1             |       h0b41bf4_0          33 KB  conda-forgelibxcrypt-4.4.36           |       hd590300_1          98 KB  conda-forgelibzlib-1.2.13             |       hd590300_5          60 KB  conda-forgeopenssl-3.2.1              |       hd590300_0         2.7 MB  conda-forgepython-3.12.2              |hab00c5b_0_cpython        30.8 MB  conda-forgepython_abi-3.12            |          4_cp312           6 KB  conda-forgetk-8.6.13                  |noxft_h4845f30_101         3.2 MB  conda-forgezlib-1.2.13                |       hd590300_5          91 KB  conda-forge------------------------------------------------------------Total:        40.8 MBThe following NEW packages will be INSTALLED:bash-completion    conda-forge/linux-64::bash-completion-2.11-ha770c72_1 conda-bash-comple~ conda-forge/linux-64::conda-bash-completion-1.7-ha770c72_1 libexpat           conda-forge/linux-64::libexpat-2.5.0-hcb278e6_1 libnsl             conda-forge/linux-64::libnsl-2.0.1-hd590300_0 libsqlite          conda-forge/linux-64::libsqlite-3.45.1-h2797004_0 libxcrypt          conda-forge/linux-64::libxcrypt-4.4.36-hd590300_1 libzlib            conda-forge/linux-64::libzlib-1.2.13-hd590300_5 python_abi         conda-forge/linux-64::python_abi-3.12-4_cp312 The following packages will be UPDATED:ca-certificates    pkgs/main::ca-certificates-2023.12.12~ --> conda-forge::ca-certificates-2024.2.2-hbcca054_0 libgcc-ng          pkgs/main::libgcc-ng-11.2.0-h1234567_1 --> conda-forge::libgcc-ng-13.2.0-h807b86a_5 libgomp              pkgs/main::libgomp-11.2.0-h1234567_1 --> conda-forge::libgomp-13.2.0-h807b86a_5 libuuid              pkgs/main::libuuid-1.41.5-h5eee18b_0 --> conda-forge::libuuid-2.38.1-h0b41bf4_0 openssl              pkgs/main::openssl-3.0.13-h7f8727e_0 --> conda-forge::openssl-3.2.1-hd590300_0 python                pkgs/main::python-3.12.1-h996f2a0_0 --> conda-forge::python-3.12.2-hab00c5b_0_cpython tk                        pkgs/main::tk-8.6.12-h1ccaba5_0 --> conda-forge::tk-8.6.13-noxft_h4845f30_101 zlib                    pkgs/main::zlib-1.2.13-h5eee18b_0 --> conda-forge::zlib-1.2.13-hd590300_5 The following packages will be SUPERSEDED by a higher-priority channel:_libgcc_mutex           pkgs/main::_libgcc_mutex-0.1-main --> conda-forge::_libgcc_mutex-0.1-conda_forge _openmp_mutex          pkgs/main::_openmp_mutex-5.1-1_gnu --> conda-forge::_openmp_mutex-4.5-2_gnu certifi            pkgs/main/linux-64::certifi-2024.2.2-~ --> conda-forge/noarch::certifi-2024.2.2-pyhd8ed1ab_0 conda              pkgs/main::conda-24.1.2-py312h06a4308~ --> conda-forge::conda-24.1.2-py312h7900ff3_0 Proceed ([y]/n)? y
Invalid choice: y
Proceed ([y]/n)? yDownloading and Extracting Packages:Preparing transaction: done                                                                                                                                                                   
Verifying transaction: done                                                                                                                                                                   
Executing transaction: done                                                                                                                                                                   
lwk@qwfys:~$

安装完成以后,要确保用户目录配置文件.condarcauto_activate_base: false被注释掉,或者将auto_activate_base: false修改为auto_activate_base: true

参考文献

  • Anaconda完全入门指南
  • Anaconda介绍、安装及使用教程
  • 请问大神们,pip install 和conda install有什么区别吗?
  • Anaconda 镜像使用帮助
  • 校园网联合镜像站|Anaconda 软件仓库镜像使用帮助
  • Bash completion support for the conda command

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 系统架构30 - 质量属性
  • Debian系APT源通用镜像加速配置
  • Pinia基本使用示例
  • C语言---单身狗问题
  • Spring MVC配置MyBatis vs. Spring Boot配置MyBatis
  • 当pytest遇上poium会擦出什么火花
  • linux 入门(七)-ffmpeg使用
  • java SSM科研管理系统myeclipse开发mysql数据库springMVC模式java编程计算机网页设计
  • 【Node.js从基础到高级运用】三、JavaScript基础
  • 洗衣洗鞋店小程序对接水洗唛打印,一键预约,支付无忧
  • MediaFoundation采集
  • Paddle上手实战——NLP经典cls任务“推特文本情感13分类”
  • C++第一弹---C++入门(上)
  • 【力扣 - 找到字符串中所有字母异位词】
  • 嵌入式学习35-网络通信UDP聊天及TCP
  • 2017-09-12 前端日报
  • Brief introduction of how to 'Call, Apply and Bind'
  • flask接收请求并推入栈
  • Git学习与使用心得(1)—— 初始化
  • HashMap剖析之内部结构
  • HTML中设置input等文本框为不可操作
  • Java|序列化异常StreamCorruptedException的解决方法
  • JS函数式编程 数组部分风格 ES6版
  • Linux Process Manage
  • Linux快速复制或删除大量小文件
  • mysql外键的使用
  • Rancher如何对接Ceph-RBD块存储
  • uva 10370 Above Average
  • vagrant 添加本地 box 安装 laravel homestead
  • 表单中readonly的input等标签,禁止光标进入(focus)的几种方式
  • 从零搭建Koa2 Server
  • 猴子数据域名防封接口降低小说被封的风险
  • 聚簇索引和非聚簇索引
  • 开源SQL-on-Hadoop系统一览
  • 名企6年Java程序员的工作总结,写给在迷茫中的你!
  • 前端路由实现-history
  • 如何使用 OAuth 2.0 将 LinkedIn 集成入 iOS 应用
  • 学习Vue.js的五个小例子
  • 学习笔记TF060:图像语音结合,看图说话
  • “十年磨一剑”--有赞的HBase平台实践和应用之路 ...
  • 选择阿里云数据库HBase版十大理由
  • #我与Java虚拟机的故事#连载17:我的Java技术水平有了一个本质的提升
  • #知识分享#笔记#学习方法
  • (2)leetcode 234.回文链表 141.环形链表
  • (C++20) consteval立即函数
  • (Note)C++中的继承方式
  • (附源码)计算机毕业设计SSM基于java的云顶博客系统
  • (四)汇编语言——简单程序
  • (五)网络优化与超参数选择--九五小庞
  • (一)硬件制作--从零开始自制linux掌上电脑(F1C200S) <嵌入式项目>
  • (原+转)Ubuntu16.04软件中心闪退及wifi消失
  • (转)es进行聚合操作时提示Fielddata is disabled on text fields by default
  • (转)甲方乙方——赵民谈找工作
  • (转)利用ant在Mac 下自动化打包签名Android程序
  • .NET / MSBuild 扩展编译时什么时候用 BeforeTargets / AfterTargets 什么时候用 DependsOnTargets?