ubuntu安装anaconda导致python问题_ubuntu如何安装软件

ubuntu安装anaconda导致python问题_ubuntu如何安装软件本文详细描述了在 Ubuntu 系统中使用 curl 下载和安装 Anaconda 包括更新包管理器 安装 Anaconda3 验证安装 管理环境 如创建 激活 卸载 以及如何在 PyCharm 中设置 conda 环境的过程

Ubuntu通过curl安装anacoda

步骤1:$ sudo apt update

步骤2:$ sudo apt install curl -y

步骤3:$ cd /tmp

在https://repo.anaconda.com/archive/

找到最新版本的替换如下的命令里的版本

curl --output anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh

~/tmp sha256sum anaconda.sh                                              

a7c0afe862f6ea19afc138bde0463abcbce1b753e8d5c474b506a2db2d  anaconda.sh

步骤4:$ bash anaconda.sh

步骤5:

bash anaconda.sh         

                          

Welcome to Anaconda3 2022.05

In order to continue the installation process, please review the license

agreement.

Please, press ENTER to continue

>>>

回车阅读协议,一直到最后,yes。

The following packages listed on https://www.anaconda.com/cryptography are included in the repository accessible

through Anaconda Distribution that relate to cryptography.

Last updated February 25, 2022

Do you accept the license terms? [yes|no]

[no] >>>

Please answer 'yes' or 'no':'

>>> yes

Anaconda3 will now be installed into this location:

/home/xxxx/anaconda3

  - Press ENTER to confirm the location

  - Press CTRL-C to abort the installation

  - Or specify a different location below

确定安装位置,回车:

Anaconda3 will now be installed into this location:

/home/xxx/anaconda3

  - Press ENTER to confirm the location

  - Press CTRL-C to abort the installation

  - Or specify a different location below

[/home/xxxx/anaconda3] >>>

等待安装完成:

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 the installer to initialize Anaconda3

by running conda init? [yes|no]

[no] >>> yes

no change     /home/xxxx/anaconda3/condabin/conda

no change     /home/xxxx/anaconda3/bin/conda

no change     /home/xxxx/anaconda3/bin/conda-env

no change     /home/xxxx/anaconda3/bin/activate

no change     /home/xxxx/anaconda3/bin/deactivate

no change     /home/xxxx/anaconda3/etc/profile.d/conda.sh

no change     /home/xxxx/anaconda3/etc/fish/conf.d/conda.fish

no change     /home/xxxx/anaconda3/shell/condabin/Conda.psm1

no change     /home/xxxx/anaconda3/shell/condabin/conda-hook.ps1

no change     /home/xxxx/anaconda3/lib/python3.9/site-packages/xontrib/conda.xsh

no change     /home/xxxx/anaconda3/etc/profile.d/conda.csh

modified      /home/xxxx/.zshrc

如果出现以下输出,则安装成功:

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

If you'd prefer that conda's base environment not be activated on startup,

   set the auto_activate_base parameter to false:

conda config --set auto_activate_base false

Thank you for installing Anaconda3!

===========================================================================

Working with Python and Jupyter is a breeze in DataSpell. It is an IDE

designed for exploratory data analysis and ML. Get better data insights

with DataSpell.

DataSpell for Anaconda is available at: https://www.anaconda.com/dataspell

补充:

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

关闭当前命令行,并重新打开,刚刚安装和初始化Anaconda设置才可以生效。

重新打开一个终端,默认直接进入conda的base环境,如下

(bash)/home/xxxx:$

需要手动关闭:

If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false:

如果您希望 conda 的基础环境在启动时不被激活,请将 auto_activate_base 参数设置为 false

设置命令如下:

conda config --set auto_activate_base false

执行完以上命令,需要重启终端才能生效,想要再次进入到conda的base环境,执行以下命令:

conda activate base

步骤5:

激活当前环境变量,重新启动系统或者执行以下命令行,让环境变量生效:

# 默认是bash配置文件

$ source ~/.bashrc

步骤6验证conda的安装:

$ conda list

 packages in environment at /home/xxxx/anaconda3:

#

# Name                    Version                   Build  Channel

_ipyw_jlab_nb_ext_conf    0.1.0            py39h06a4308_1  

_libgcc_mutex             0.1                        main  

_openmp_mutex             4.5                       1_gnu  

aiohttp                   3.8.1            py39h7f8727e_1  

aiosignal                 1.2.0              pyhd3eb1b0_0  

alabaster                 0.7.12             pyhd3eb1b0_0  

anaconda                  2022.05                  py39_0  

anaconda-client           1.9.0            py39h06a4308_0  

anaconda-navigator        2.1.4            py39h06a4308_0  

anaconda-project          0.10.2             pyhd3eb1b0_0  

anyio                     3.5.0            py39h06a4308_0  

appdirs                   1.4.4              pyhd3eb1b0_0  

argon2-cffi               21.3.0             pyhd3eb1b0_0  

argon2-cffi-bindings      21.2.0           py39h7f8727e_0  

arrow                     1.2.2              pyhd3eb1b0_0  

astroid                   2.6.6            py39h06a4308_0  

astropy                   5.0.4            py39hce1f21e_0  

asttokens                 2.0.5              pyhd3eb1b0_0  

查看conda的版本号:

(base) conda --version                       

conda 4.12.0

怎样卸载Anaconda:

$ rm -rf ~/anaconda3

conda的基础使用:

  1. 环境管理:

# 1.查看conda的版本号

conda --version

# 2.查看虚拟环境列表

conda info --envs

# 3.创建虚拟环境并指定python的版本号为3.8

conda create -n virtualname pip python=3.9

# 4.激活虚拟环境

conda activate virtualname

# 5.退出虚拟环境

conda deactivate

# 6.删除虚拟环境

conda remove --name virtualname --all

  1. 包管理:

# 1.安装包

conda install PackageName

# 2.安装多个包

conda install name1 name2 ...

# 3.安装包并指定版本号

conda install PackageName=版本号

# 4.卸载包

conda remove PackageName

# 5.更新包

conda update PackageName

# 6.更新环境中的所有包

conda update --all

# 7.列出已安装的包

conda list

# 8.搜寻包

conda search PackageName

pycharm使用anaconda环境:

步骤1创建新的环境:

conda create --name <env_name> <package_names>

<env_name> 即创建的环境名。建议以英文命名,且不加空格,名称两边不加尖括号“<>”
<package_names> 即安装在环境中的包名。名称两边不加尖括号“<>”

① 如果要安装指定的版本号,则只需要在包名后面以 python=3.9 和版本号的形式执行。

如: conda create --name python2 python=2.7,即创建一个名为“pytorch”的环境,环境中安装版本为2.7的python。

② 如果要在新创建的环境中创建多个包,则直接在 <package_names> 后以空格隔开,添加多个包名即可。

如: conda create -n python3 python=3.5 numpy pandas ,即创建一个名为“pytorch”的环境,环境中安装版本为3.5的python,同时也安装了numpy和pandas库。

--name 同样可以替换为 -n 。

在命令行中输入下列指令创建虚拟环境:

conda create -n pytorch1.12  python==3.9

其中 pytorch为本次创建的虚拟环境的名称,1.12为创建的pytorch虚拟环境的版本:

Collecting package metadata (current_repodata.json): done

Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.

Collecting package metadata (repodata.json): done

Solving environment: done

==> WARNING: A newer version of conda exists. <==

  current version: 4.12.0

  latest version: 22.9.0

Please update conda by running

    $ conda update -n base -c defaults conda

Package Plan

  environment location: /home/xxxx/anaconda3/envs/pytorch

  added / updated specs:

    - numpy

    - python==3.9

The following packages will be downloaded:

    package                    |            build

    ---------------------------|-----------------

    _openmp_mutex-5.1          |            1_gnu          21 KB

    ca-certificates-2022.07.19 |       h06a4308_0         124 KB

    certifi-2022.9.24          |   py39h06a4308_0         154 KB

    ld_impl_linux-64-2.38      |       h_1         654 KB

    libgcc-ng-11.2.0           |       h_1         5.3 MB

    libgomp-11.2.0             |       h_1         474 KB

    libstdcxx-ng-11.2.0        |       h_1         4.7 MB

    ncurses-6.3                |       h5eee18b_3         781 KB

    numpy-1.23.1               |   py39h6c91a56_0          11 KB

    numpy-base-1.23.1          |   py39ha15fc14_0         5.6 MB

    openssl-1.1.1q             |       h7f8727e_0         2.5 MB

    pip-22.2.2                 |   py39h06a4308_0         2.3 MB

    python-3.9.0               |       hdb3f193_2        18.1 MB

    setuptools-63.4.1          |   py39h06a4308_0         1.1 MB

    sqlite-3.39.3              |       h_0         1.1 MB

    tk-8.6.12                  |       h1ccaba5_0         3.0 MB

    tzdata-2022c               |       h04d1e81_0         107 KB

    xz-5.2.6                   |       h5eee18b_0         394 KB

    zlib-1.2.12                |       h5eee18b_3         103 KB

    ------------------------------------------------------------

                                           Total:        46.5 MB

Proceed ([y]/n)? y

Downloading and Extracting Packages

tzdata-2022c         | 107 KB    | | 100%

numpy-base-1.23.1    | 5.6 MB    | | 100%

zlib-1.2.12          | 103 KB    | | 100%

_openmp_mutex-5.1    | 21 KB     | | 100%

python-3.9.0         | 18.1 MB   | | 100%

sqlite-3.39.3        | 1.1 MB    | | 100%

libgcc-ng-11.2.0     | 5.3 MB    | | 100%

pip-22.2.2           | 2.3 MB    | | 100%

tk-8.6.12            | 3.0 MB    | | 100%

ncurses-6.3          | 781 KB    | | 100%

xz-5.2.6             | 394 KB    | | 100%

numpy-1.23.1         | 11 KB     | | 100%

libstdcxx-ng-11.2.0  | 4.7 MB    | | 100%

libgomp-11.2.0       | 474 KB    | | 100%

setuptools-63.4.1    | 1.1 MB    | | 100%

ld_impl_linux-64-2.3 | 654 KB    | | 100%

ca-certificates-2022 | 124 KB    | | 100%

certifi-2022.9.24    | 154 KB    | | 100%

openssl-1.1.1q       | 2.5 MB    | | 100%

Preparing transaction: done

Verifying transaction: done

Executing transaction: done

#

# To activate this environment, use

#

#     $ conda activate pytorch

#

# To deactivate an active environment, use

#

#     $ conda deactivate

步骤2:安装结束之后输入以下指令激活虚拟环境

conda activate pytorch

步骤3:设置pycharm

然后我们打开pycharm,选择对应的conda环境。

选择‘’Add new Interpreter”添加刚才建立的虚拟环境。

选择“conda environment”,“Interpreter”,填写“/home/xxxx/anaconda3/env/bin/python3.9”

编程小号
上一篇 2024-12-07 22:42
下一篇 2024-12-07 22:36

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://sigusoft.com/dataspell/4569.html