昨天训练数据的时候,发现Anaconda占用C盘达到了20G(暑假在cmd状态下安装的,默认下载到了C盘),心道再创建几个环境,C盘就要爆红了,于是重装Anaconda到了D盘,不过之后的初始化并不顺利--创建pytorch环境总是失败,网上查阅了许多资料:配置path环境变量,关闭VPN,.condarc文件删除或添加路径,更换清华源等等都无果。报错如下:
>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "C:\Users\86150\anaconda3\Lib\site-packages\conda\exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\main.py", line 54, in main_subshell
parser = generate_parser(add_help=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\conda_argparse.py", line 127, in generate_parser
configure_parser_plugins(sub_parsers)
File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\conda_argparse.py", line 354, in configure_parser_plugins
else set(find_commands()).difference(plugin_subcommands)
^^^^^^^^^^^^^^^
File "C:\Users\86150\anaconda3\Lib\site-packages\conda\cli\find_commands.py", line 71, in find_commands
for entry in os.scandir(dir_path):
^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: 'D:\\1瀵邦喕淇?缁嬪\ue0c5绨璡瀵邦喕淇妛eb瀵\ue1b9偓閸欐垼鈧\ue100懎浼愰崗绌僤ll'
`$ C:\Users\86150\anaconda3\Scripts\conda-script.py config --set show_channel_urls yes`
environment variables:
CIO_TEST=<not set>
CLASSPATH=.;C:\Program Files\Java\jdk1.8.0_221\bin;C:\Program
Files\Java\jdk1.8.0_221\lib\dt.jar;C:\Program
Files\Java\jdk1.8.0_221\lib\tools.jar;D:\sqljdbc4\sqljdbc4.jar
CONDA_DEFAULT_ENV=pytorch
CONDA_EXE=C:\Users\86150\anaconda3\condabin\..\Scripts\conda.exe
CONDA_EXES="C:\Users\86150\anaconda3\condabin\..\Scripts\conda.exe"
CONDA_PREFIX=C:\Users\86150\anaconda3\envs\pytorch
CONDA_PREFIX_1=C:\Users\86150\anaconda3
CONDA_PROMPT_MODIFIER=(pytorch)
CONDA_PYTHON_EXE=C:\Users\86150\anaconda3\python.exe
CONDA_ROOT=C:\Users\86150\anaconda3
CONDA_SHLVL=2
CURL_CA_BUNDLE=<not set>
HOMEPATH=\Users\86150
LD_PRELOAD=<not set>
NODE_PATH=D:\1微信小程序\node\node_global\node_modules
PATH=C:\Users\86150\anaconda3\envs\pytorch;C:\Users\86150\anaconda3\envs\py
torch\Library\mingw-
w64\bin;C:\Users\86150\anaconda3\envs\pytorch\Library\usr\bin;C:\Users
\86150\anaconda3\envs\pytorch\Library\bin;C:\Users\86150\anaconda3\env
s\pytorch\Scripts;C:\Users\86150\anaconda3\envs\pytorch\bin;C:\Users\8
6150\anaconda3\condabin;E:\;E:\VM\bin;E:\app\Qracleinstall\product\12.
2.0\dbhome_1\bin;C:\Program Files\Microsoft MPI\Bin;C:\WINDOWS\system3
2;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPower
Shell\v1.0;C:\WINDOWS\System32\OpenSSH;E:\bin;C:\Program
Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program
Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Program
Files\Java\jdk1.8.0_221\bin;D:\apache-
tomcat-9.0.37-windows-x64\apache-tomcat-9.0.37\bin;C:\Program
Files\Java\jdk1.8.0_221\jre\bin;C:\Program Files\dotnet;C:\Program
Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;D:\x64\瀵邦喕淇妛
eb瀵偓閸欐垼鈧懎浼愰崗绌僤ll;D:\1瀵邦喕淇?缁嬪绨璡瀵邦喕淇妛eb瀵偓閸欐垼鈧懎浼愰崗绌僤ll;D:\1瀵邦喕淇婄亸蹇曗柤
;\node;C:\Program Files (x86)\MySQL;D:\Git\Git\cmd;E:\Xshell;C:\Users\
86150\anaconda3;C:\Users\86150\anaconda3\Library\mingw-
w64\bin;C:\Users\86150\anaconda3\Library\usr\bin;C:\Users\86150\anacon
da3\Library\bin;C:\Users\86150\anaconda3\Scripts;D:\Python\python3.11.
5\Scripts;D:\Python\python3.11.5;C:\Users\MySQL\MySQL Server 8.0\bin;C
:\Users\86150\AppData\Local\Microsoft\WindowsApps;.;C:\Users\86150\.do
tnet\tools;C:\Users\86150\AppData\Local\Microsoft\WindowsApps;D:\1瀵邦喕淇
婄亸蹇曗柤鎼村猾node\node_global;E:\Python\PyCharm Community Edition
2023.1.3\bin;.;C:\Users\86150\Python 3.11;D:\Microsoft VS Code\bin
PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\Windows
PowerShell\v1.0\Modules;C:\Users\86150\Desktop\编程;
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=C:\Users\86150\anaconda3\Library\ssl\cacert.pem
active environment : pytorch
active env location : C:\Users\86150\anaconda3\envs\pytorch
shell level : 2
user config file : C:\Users\86150\.condarc
populated config files : C:\Users\86150\.condarc
conda version : 23.7.4
conda-build version : 3.26.1
python version : 3.11.5.final.0
virtual packages : __archspec=1=x86_64
__win=0=0
base environment : C:\Users\86150\anaconda3 (writable)
conda av data dir : C:\Users\86150\anaconda3\etc\conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\86150\anaconda3\pkgs
C:\Users\86150\.conda\pkgs
C:\Users\86150\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\86150\anaconda3\envs
C:\Users\86150\.conda\envs
C:\Users\86150\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/23.7.4 requests/2.31.0 CPython/3.11.5 Windows/10 Windows/10.0.19045
administrator : False
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
Example: conda --no-plugins install <package>
Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.
Example: CONDA_NO_PLUGINS=true conda install <package>
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers? [y/N]:
No report sent. To permanently opt-out, use
$ 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的版本号
>>> import torch
>>> torch.__version__
'2.1.1+cpu'
这下终于尘埃落定,解决掉这个难题了。