anaconda运行报错解决及配置及安装pytorch

1. Import-Module : 无法加载文件 D:\ProgramData\anaconda3\shell\condabin\Conda.psm1,因为在此系统上禁止运行脚本

1、找到Anaconda Powershell Prompt图标;

2、右击,然后选择管理员身份运行;

3、在PowerShell窗口输入 Set-ExecutionPolicy RemoteSigned 命令,然后enter;

4、选择【Yes】;

5、打开Anaconda Prompt,在该窗口中输入conda init powershell,之后重启软件即可。

 配置文件内容:

envs_dirs:
  - D:\envfile\python\anaconda\envs
  - D:\ProgramData\anaconda3\envs
pkgs_dirs:
  - D:\envfile\python\anaconda\pkgs
  - D:\ProgramData\anaconda3\pkgs
show_channel_urls: true
report_errors: true
ssl_verify: false
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - 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/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  - defaults
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

 第一次使用上面channel安装pytorch还是可以,后面由于其他原因卸载后重新安装就不行了,需要把上面的channels和customer_channels的清华源删除再试,就可以了,估计是被清华源加入黑名单了

也可以试下下面内容

envs_dirs:
  - D:\envfile\python\anaconda\envs
  - D:\ProgramData\anaconda3\envs
pkgs_dirs:
  - D:\envfile\python\anaconda\pkgs
  - D:\ProgramData\anaconda3\pkgs
show_channel_urls: True
report_errors: True
ssl_verify: False
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
  - defaults
debug: False

 如果上面不行,就下载文件进行安装 

方法1 安装pytorch: https://pytorch.org/get-started/locally/#windows-anaconda

 

方法2 下载.whl文件后本地pip install安装(梯子随意,网线即可,快速稳定)

torch各个历史版本的.whl文件网站:

https://download.pytorch.org/whl/torch_stable.html

 查看cuda版本可以通过这里: 帮助->系统信息->组件

 

 

.whl文件下载好后,找到这个文件的地址,在我的电脑上默认下载到“下载”这个文件夹中:

现在打开Anaconda Prompt,进入你事先创建好的环境,利用cd命令进入这个.whl文件所在的文件夹,利用命令

pip install 文件名.whl

如果有报错,根据提醒进行操作即可

 

posted @ 2024-04-09 10:07  study_php_java_C++  阅读(139)  评论(0编辑  收藏  举报