博客列表 >Anaconda 安装 国内镜像问题解决方案

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

哈
原创
2022年03月15日 10:33:372630浏览

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

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

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

遇到问题:报错:

  1. #安装在d盘
  2. 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 生成该文件之后再修改。

  1. channels:
  2. - defaults
  3. show_channel_urls: true
  4. default_channels:
  5. - http://mirrors.aliyun.com/anaconda/pkgs/main
  6. - http://mirrors.aliyun.com/anaconda/pkgs/r
  7. - http://mirrors.aliyun.com/anaconda/pkgs/msys2
  8. custom_channels:
  9. conda-forge: http://mirrors.aliyun.com/anaconda/cloud
  10. msys2: http://mirrors.aliyun.com/anaconda/cloud
  11. bioconda: http://mirrors.aliyun.com/anaconda/cloud
  12. menpo: http://mirrors.aliyun.com/anaconda/cloud
  13. pytorch: http://mirrors.aliyun.com/anaconda/cloud
  14. simpleitk: http://mirrors.aliyun.com/anaconda/cloud
  15. ssl_verify: false

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

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

再次执行语句conda update anaconda-navigator

done 可以连网更新

  1. (base) C:\Windows\system32>conda update anaconda-navigator
  2. Collecting package metadata (current_repodata.json): done
  3. Solving environment: done
  4. ## Package Plan ##
  5. environment location: D:\Avaconda
  6. added / updated specs:
  7. - anaconda-navigator
  8. The following packages will be downloaded:
  9. package | build
  10. ---------------------------|-----------------
  11. anaconda-navigator-2.1.1 | py39_0 5.4 MB defaults
  12. ------------------------------------------------------------
  13. Total: 5.4 MB
  14. The following packages will be SUPERSEDED by a higher-priority channel:
  15. anaconda-navigator pkgs/main --> anaconda/pkgs/main
  16. Proceed ([y]/n)?

输入y执行,遇到问题:

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

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

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

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

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

尝试conda clean —all —yes

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

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

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

记录一下成功时刻:

  1. Downloading and Extracting Packages
  2. 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)
  3. 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)
  4. python-3.6.13 | 17.7 MB | ############################################################################ | 100%
  5. TypeError('not all arguments converted during string formatting',)
  1. /*看到100%好感动呜呜呜呜!为了这三个done我折腾了至少一整天!!*/
  2. Downloading and Extracting Packages
  3. zstd-1.4.9 | 1.3 MB | ############################################################################################## | 100%
  4. opencv-3.3.1 | 96.7 MB | ############################################################################################## | 100%
  5. lz4-c-1.9.3 | 141 KB | ############################################################################################## | 100%
  6. xz-5.2.5 | 333 KB | ############################################################################################## | 100%
  7. openssl-1.0.2u | 5.8 MB | ############################################################################################## | 100%
  8. libtiff-4.2.0 | 1.1 MB | ############################################################################################## | 100%
  9. Preparing transaction: done
  10. Verifying transaction: done
  11. Executing transaction: done

打开CMD输入:python

import cv2
print(cv2.version)

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

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

搞定!撒花!

pip安装包功能

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

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

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

点开,修改内容为:

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

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

保存pip文件

本文转自:https://blog.csdn.net/weixin_51688299/article/details/123122283

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议