手记

Anaconda 安装 国内镜像问题解决方案

遇到问题:安装2021版本后无法打开Anaconda Navigator

解决方案:使用管理员身份打开Avaconda Prompt,输入conda update anaconda-navigator

遇到问题:报错:

#安装在d盘
HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>

分析是国内镜像源问题

解决方案:添加镜像文件

Linux用户可以通过修改用户目录下的 .condarc 文件。

Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

channels:
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.aliyun.com/anaconda/pkgs/main
  - http://mirrors.aliyun.com/anaconda/pkgs/r
  - http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
  conda-forge: http://mirrors.aliyun.com/anaconda/cloud
  msys2: http://mirrors.aliyun.com/anaconda/cloud
  bioconda: http://mirrors.aliyun.com/anaconda/cloud
  menpo: http://mirrors.aliyun.com/anaconda/cloud
  pytorch: http://mirrors.aliyun.com/anaconda/cloud
  simpleitk: http://mirrors.aliyun.com/anaconda/cloud
ssl_verify: false

注:1.由于更新过快难以同步,我们不同步pytorch-nightly, pytorch-nightly-cpu, ignite-nightly这三个包;

2.最后一行是酌情加上去的,此处根据具体情况考虑是否增加

再次执行语句conda update anaconda-navigator

done 可以连网更新

(base) C:\Windows\system32>conda update anaconda-navigator
Collecting package metadata (current_repodata.json): done
Solving environment: done
 
## Package Plan ##
 
  environment location: D:\Avaconda
 
  added / updated specs:
    - anaconda-navigator
 
 
The following packages will be downloaded:
 
    package                    |            build
    ---------------------------|-----------------
    anaconda-navigator-2.1.1   |           py39_0         5.4 MB  defaults
    ------------------------------------------------------------
                                           Total:         5.4 MB
 
The following packages will be SUPERSEDED by a higher-priority channel:
 
  anaconda-navigator                              pkgs/main --> anaconda/pkgs/main
 
 
Proceed ([y]/n)?

输入y执行,遇到问题:

Proceed ([y]/n)? y
 
 
Downloading and Extracting Packages
anaconda-navigator-2 | 5.4 MB    |                                                                   |   0%
 
[Errno 2] No such file or directory: 'D:\\Avaconda\\pkgs\\anaconda-navigator-2.1.1-py39_0.conda'
 
系统找不到指定的路径。
系统找不到指定的路径。

上网寻找解决方案,有博主说添加路径,但是在安装时候已经添加过;于是卸载2021版本,重新下载安装Anaconda3,再次尝试

能够正常打开Anaconda Navigator,使用管理员身份打开Avaconda Prompt,输入conda update anaconda-navigator,报错:

ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::tqdm-4.62.3-pyhd3eb1b0_1'.
CondaError: Cannot link a source that does not exist. D:\Anaconda\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.
Attempting to roll back.
 
 
CondaError: Cannot link a source that does not exist. D:\Anaconda\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.

重新添加了一遍路径,没能解决问题。

尝试conda clean --all --yes

再运行conda update conda,不再出现相同error,成功更新。

执行以下语句,安装opencv包:

conda install -c https://conda.anaconda.org/menpo opencv

记录一下成功时刻:

Downloading and Extracting Packages
python-3.6.13        | 17.7 MB   | ###########################################################################9 | 100% WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(144): Could not remove or rename D:\Anaconda\pkgs\python-3.6.13-h3758d61_0\DLLs\tcl86t.dll.  Please remove this file manually (you may need to reboot to free file handles)
WARNING conda.gateways.disk.delete:unlink_or_rename_to_trash(144): Could not remove or rename D:\Anaconda\pkgs\python-3.6.13-h3758d61_0\DLLs\tcl86t.dll.  Please remove this file manually (you may need to reboot to free file handles)
python-3.6.13        | 17.7 MB   | ############################################################################ | 100%
 
TypeError('not all arguments converted during string formatting',)
/*看到100%好感动呜呜呜呜!为了这三个done我折腾了至少一整天!!*/
 
Downloading and Extracting Packages
zstd-1.4.9           | 1.3 MB    | ############################################################################################## | 100%
opencv-3.3.1         | 96.7 MB   | ############################################################################################## | 100%
lz4-c-1.9.3          | 141 KB    | ############################################################################################## | 100%
xz-5.2.5             | 333 KB    | ############################################################################################## | 100%
openssl-1.0.2u       | 5.8 MB    | ############################################################################################## | 100%
libtiff-4.2.0        | 1.1 MB    | ############################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

打开CMD输入:python

import cv2
print(cv2.version)

如果输出版本则证明安装成功

python
Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.__version__)
3.3.1

搞定!撒花!

pip安装包功能

在文件搜索框输入%APPDATA%→出现C:\Users***\AppData\Roaming→查看是否有pip文件夹;

若有,点进去看是否有文件:pip.ini

若没有,依次新建文件夹pip,以记事本新建pip文件并重命名为pip.ini

点开,修改内容为:

[global]
timeout = 6000
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

PS:第三行可以根据需要修改为之前步骤中选择的镜像地址,这里选择了阿里云

保存pip文件

0人推荐
随时随地看视频
慕课网APP