opencv入门——anaconda安装

📢安装前最好先删除电脑上别的python版本。
📢 anaconda 自带 Python 环境,可以不再额外安装Python。

一、Anacond的介绍

Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB),如果只需要某些包,或者需要节省带宽或存储空间,也可以使用Miniconda这个较小的发行版(仅包含conda和 Python)。

Conda是一个开源的包、环境管理器,可以用于在同一个机器上安装不同版本的软件包及其依赖,并能够在不同的环境之间切换。

Anaconda包括Conda、Python以及一大堆安装好的工具包,比如:numpy、pandas等。

二、下载

1. 官网下载

下载地址:

2. 点击download

3. 环境选择

根据个人电脑系统,可以选择Windows、macOS、Linux。

4. 选择对应的版本下载

版本: Anaconda3–Python3.7

下载完成。

三、安装anaconda

1. 双击exe文件

双击下载好的Anaconda3-2019.10-Windows-x86_64 .exe文件,出现如下界面,点击 Next 即可。

2. 点击I agree

3. 点击Just Me

Install for: Just me还是All Users?假如你的电脑有好几个 Users ,才需要考虑这个问题。

其实我们电脑一般就一个 User,就我们一个人使用;如果是以管理员身份为所有用户安装,选择All Users。继续点击 Next 。

4. 选择安装目录

建议按系统默认的路径。

5. 高级选项

  • 勾选“Add Anaconda to my PATH environment variable”,即:添加 Anaconda 至环境变量。
  • 如果你打算使用多个版本的 Anaconda 或者多个版本的 Python,那就不要勾选“Register Anaconda as my default Python 3.7”


安装。



是与勾选都行,最好按照默认的安装。

四、配置环境变量

  1. 📢📢📢 下载完之后,尽量的按照anaconda默认的行为安装,打钩的两个地方都勾上,它会自动将bin目录加入到环境变量path中去

  1. 📌若取消打钩,需要自己添加环境变量。
    Windows:
    控制面板系统和安全系统高级系统设置环境变量系统变量Path编辑新建添加 anaconda的安装目录的Scripts文件夹

比如我的路径是:D:\software\Anaconda\Scripts
内容根据个人安装路径调整。

验证:
打开cmd:

  • 输出conda --version
    如果输出conda 版本号,说明环境变量设置成功了。
  • 输出conda list
    显示很多库名和版本号列表,说明安装成功。
  • 查看Python版本:

五、更新失败问题

输入conda upgrade --all

若可以执行更新指令,但是发现更新的速度非常慢,可以根据下面2.1~2.2的步骤进行换源处理。

1. 问题

输入conda search numpy,或者输入conda upgrade --all,发现出现错误:

conda search numpy
Loading channels: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Max retries exceeded with url: /anaconda/pkgs/free/win-64/repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
conda upgrade --all
Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Max retries exceeded with url: /anaconda/pkgs/free/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))

2. 解决方式

2.1 指定清华镜像:

执行命令,生成.condarc文件

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

2.2 删除.condarc文件里的defaul

输入conda config --show,显示如下:

C:\Users\86571>conda config --show

add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
– ca-certificates
– certifi
– openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_activate_base: True
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
channels:
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
– defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: D:\software\Anaconda\conda-bld
custom_channels:
pkgs/main: https://repo.anaconda.com
pkgs/r: https://repo.anaconda.com
pkgs/msys2: https://repo.anaconda.com
pkgs/pro: https://repo.anaconda.com
custom_multichannels:
defaults:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- https://repo.anaconda.com/pkgs/msys2
local:
debug: False
default_channels:
https://repo.anaconda.com/pkgs/main
https://repo.anaconda.com/pkgs/r
https://repo.anaconda.com/pkgs/msys2
default_python: 3.7
······

输入命令: conda --help,找到配置文件.condarc的路径 ,将上述显示的配置信息中-defaults所在行删除保存即可。

C:\Users\86571>conda --help
usage: conda-script.py [-h] [-V] command …
conda is a tool for managing and deploying applications, environments and packages.
Options:
positional arguments:
command
clean Remove unused packages and caches.
config Modify configuration values in .condarc. This is modeled
after the git config command. Writes to the user .condarc
file (C:\Users\86571\.condarc) by default.

在上面显示信息中找到config,其告诉.condarc文件的路径,用记事本打开并删除-defaults那一行即可。

在这里插入图片描述

2.3 镜像链接的https修改成http

设置清华镜像,去c盘删除文件里的defaul ,但都是不可以的话,解决方法:

修改.condarc文件,把镜像链接的https修改成http就可以了。因为镜像源为了提高安全性使用了ssl证书进行加密,但是原链接也能用。

2.4 测试成功

学习:
Anaconda安装及更新失败解决方式

Anaconda使用conda连接网络出现错误(CondaHTTPError: HTTP 000 CONNECTION FAILED for url)

Anaconda完全入门指南

Anaconda详细安装及使用教程(带图文)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值