• conda创建pytorch环境报错


    昨天训练数据的时候,发现Anaconda占用C盘达到了20G(暑假在cmd状态下安装的,默认下载到了C盘),心道再创建几个环境,C盘就要爆红了,于是重装Anaconda到了D盘,不过之后的初始化并不顺利--创建pytorch环境总是失败,网上查阅了许多资料:配置path环境变量,关闭VPN,.condarc文件删除或添加路径,更换清华源等等都无果。报错如下:

    1. >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
    2. Traceback (most recent call last):
    3. File "C:\Users\86150\anaconda3\Lib\site-packages\conda\exception_handler.py", line 17, in __call__
    4. return func(*args, **kwargs)
    5. ^^^^^^^^^^^^^^^^^^^^^
    6. File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\main.py", line 54, in main_subshell
    7. parser = generate_parser(add_help=True)
    8. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    9. File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\conda_argparse.py", line 127, in generate_parser
    10. configure_parser_plugins(sub_parsers)
    11. File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\conda_argparse.py", line 354, in configure_parser_plugins
    12. else set(find_commands()).difference(plugin_subcommands)
    13. ^^^^^^^^^^^^^^^
    14. File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\find_commands.py", line 71, in find_commands
    15. for entry in os.scandir(dir_path):
    16. ^^^^^^^^^^^^^^^^^^^^
    17. OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: 'D:\\1瀵邦喕淇?缁嬪\ue0c5绨璡瀵邦喕淇妛eb瀵\ue1b9偓閸欐垼鈧\ue100懎浼愰崗绌僤ll'
    18. `$ C:\Users\86150\anaconda3\Scripts\conda-script.py config --set show_channel_urls yes`
    19. environment variables:
    20. CIO_TEST=<not set>
    21. CLASSPATH=.;C:\Program Files\Java\jdk1.8.0_221\bin;C:\Program
    22. Files\Java\jdk1.8.0_221\lib\dt.jar;C:\Program
    23. Files\Java\jdk1.8.0_221\lib\tools.jar;D:\sqljdbc4\sqljdbc4.jar
    24. CONDA_DEFAULT_ENV=pytorch
    25. CONDA_EXE=C:\Users\86150\anaconda3\condabin\..\Scripts\conda.exe
    26. CONDA_EXES="C:\Users\86150\anaconda3\condabin\..\Scripts\conda.exe"
    27. CONDA_PREFIX=C:\Users\86150\anaconda3\envs\pytorch
    28. CONDA_PREFIX_1=C:\Users\86150\anaconda3
    29. CONDA_PROMPT_MODIFIER=(pytorch)
    30. CONDA_PYTHON_EXE=C:\Users\86150\anaconda3\python.exe
    31. CONDA_ROOT=C:\Users\86150\anaconda3
    32. CONDA_SHLVL=2
    33. CURL_CA_BUNDLE=<not set>
    34. HOMEPATH=\Users\86150
    35. LD_PRELOAD=<not set>
    36. NODE_PATH=D:\1微信小程序\node\node_global\node_modules
    37. PATH=C:\Users\86150\anaconda3\envs\pytorch;C:\Users\86150\anaconda3\envs\py
    38. torch\Library\mingw-
    39. w64\bin;C:\Users\86150\anaconda3\envs\pytorch\Library\usr\bin;C:\Users
    40. \86150\anaconda3\envs\pytorch\Library\bin;C:\Users\86150\anaconda3\env
    41. s\pytorch\Scripts;C:\Users\86150\anaconda3\envs\pytorch\bin;C:\Users\8
    42. 6150\anaconda3\condabin;E:\;E:\VM\bin;E:\app\Qracleinstall\product\12.
    43. 2.0\dbhome_1\bin;C:\Program Files\Microsoft MPI\Bin;C:\WINDOWS\system3
    44. 2;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPower
    45. Shell\v1.0;C:\WINDOWS\System32\OpenSSH;E:\bin;C:\Program
    46. Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program
    47. Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Program
    48. Files\Java\jdk1.8.0_221\bin;D:\apache-
    49. tomcat-9.0.37-windows-x64\apache-tomcat-9.0.37\bin;C:\Program
    50. Files\Java\jdk1.8.0_221\jre\bin;C:\Program Files\dotnet;C:\Program
    51. Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;D:\x64\瀵邦喕淇妛
    52. eb瀵偓閸欐垼鈧懎浼愰崗绌僤ll;D:\1瀵邦喕淇?缁嬪绨璡瀵邦喕淇妛eb瀵偓閸欐垼鈧懎浼愰崗绌僤ll;D:\1瀵邦喕淇婄亸蹇曗柤
    53. ;\node;C:\Program Files (x86)\MySQL;D:\Git\Git\cmd;E:\Xshell;C:\Users\
    54. 86150\anaconda3;C:\Users\86150\anaconda3\Library\mingw-
    55. w64\bin;C:\Users\86150\anaconda3\Library\usr\bin;C:\Users\86150\anacon
    56. da3\Library\bin;C:\Users\86150\anaconda3\Scripts;D:\Python\python3.11.
    57. 5\Scripts;D:\Python\python3.11.5;C:\Users\MySQL\MySQL Server 8.0\bin;C
    58. :\Users\86150\AppData\Local\Microsoft\WindowsApps;.;C:\Users\86150\.do
    59. tnet\tools;C:\Users\86150\AppData\Local\Microsoft\WindowsApps;D:\1瀵邦喕淇
    60. 婄亸蹇曗柤鎼村猾node\node_global;E:\Python\PyCharm Community Edition
    61. 2023.1.3\bin;.;C:\Users\86150\Python 3.11;D:\Microsoft VS Code\bin
    62. PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\Windows
    63. PowerShell\v1.0\Modules;C:\Users\86150\Desktop\编程;
    64. REQUESTS_CA_BUNDLE=<not set>
    65. SSL_CERT_FILE=C:\Users\86150\anaconda3\Library\ssl\cacert.pem
    66. active environment : pytorch
    67. active env location : C:\Users\86150\anaconda3\envs\pytorch
    68. shell level : 2
    69. user config file : C:\Users\86150\.condarc
    70. populated config files : C:\Users\86150\.condarc
    71. conda version : 23.7.4
    72. conda-build version : 3.26.1
    73. python version : 3.11.5.final.0
    74. virtual packages : __archspec=1=x86_64
    75. __win=0=0
    76. base environment : C:\Users\86150\anaconda3 (writable)
    77. conda av data dir : C:\Users\86150\anaconda3\etc\conda
    78. conda av metadata url : None
    79. channel URLs : https://repo.anaconda.com/pkgs/main/win-64
    80. https://repo.anaconda.com/pkgs/main/noarch
    81. https://repo.anaconda.com/pkgs/r/win-64
    82. https://repo.anaconda.com/pkgs/r/noarch
    83. https://repo.anaconda.com/pkgs/msys2/win-64
    84. https://repo.anaconda.com/pkgs/msys2/noarch
    85. package cache : C:\Users\86150\anaconda3\pkgs
    86. C:\Users\86150\.conda\pkgs
    87. C:\Users\86150\AppData\Local\conda\conda\pkgs
    88. envs directories : C:\Users\86150\anaconda3\envs
    89. C:\Users\86150\.conda\envs
    90. C:\Users\86150\AppData\Local\conda\conda\envs
    91. platform : win-64
    92. user-agent : conda/23.7.4 requests/2.31.0 CPython/3.11.5 Windows/10 Windows/10.0.19045
    93. administrator : False
    94. netrc file : None
    95. offline mode : False
    96. An unexpected error has occurred. Conda has prepared the above report.
    97. If you suspect this error is being caused by a malfunctioning plugin,
    98. consider using the --no-plugins option to turn off plugins.
    99. Example: conda --no-plugins install <package>
    100. Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
    101. the command line to run the command without plugins enabled.
    102. Example: CONDA_NO_PLUGINS=true conda install <package>
    103. If submitted, this report will be used by core maintainers to improve
    104. future releases of conda.
    105. Would you like conda to send this report to the core maintainers? [y/N]:
    106. No report sent. To permanently opt-out, use
    107. $ conda config --set report_errors false

    又看到安装Anaconda时,选择JUST ME默认环境路径在annconda/env下,而选择ALL USERS默认环境路径则在C盘.anaconda/env文件夹下。卸载后又重装了Anaconda,先是选择JUST ME,报相同的错误,又重装后选择ALL USERS,创建pytorch还是相同的错误。

    无奈之下,再次把Anaconda安装到C盘,这时候执行conda create -n pytorch python=3.8命令是没问题的,环境可以成功创建。conda activate pytorch激活环境也没问题,不过最重要的一步--安装torch又出错了,pytorch官网的conda代码,清华源,华科源都报相同的错误(上述代码)。Google/GitHub/CSDN/Stack Overflow/博客园等等都查了一遍,都没出现过类似的问题。晚上睡觉的时候心想难道要重装下系统?

    还好山重水复疑无路,下午在知乎浏览技术贴的时候看到一句话“pip 或者 conda的时候经常被混合使用,这两者也通常被认为是几乎相同的,尽管他们的很多功能是重叠的。“

    突然意识到pip install 和conda install的功能应该是相同的。兴致冲冲在Anaconda Prompt命令行键入:pip3 install torch torchvision torchaudio,等待一段时间后torch终于下载成功。又进入python环境中导入的torch包,输出了torch的版本号

    1. >>> import torch
    2. >>> torch.__version__
    3. '2.1.1+cpu'

    这下终于尘埃落定,解决掉这个难题了。

  • 相关阅读:
    通过Java高仿flyme悬浮球设计
    Python 零基础入门数据分析实战之小费数据集应用
    FFmpeg日志系统、文件与目录、操作目录
    视觉slam论文、代码汇总
    【pytorch】从零开始,利用yolov5、crnn+ctc进行车牌识别
    python列出本地文件路径
    python经典百题之皮球掉落
    C语言交通查询系统
    Maven入门与开箱即用
    [机器学习笔记]K-means聚类——进行广告效果分析
  • 原文地址:https://blog.csdn.net/weixin_46653651/article/details/134490177