环境
操作系统:Windows11
开发环境:Pycharm 2021.4
虚拟环境管理:Conda
操作流程:打开Pycharm -> 打开Terminal
错误信息
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "D:\DevPrograms\Anaconda3\lib\site-packages\conda\exceptions.py", line 1129, in __call__
return func(*args, **kwargs)
File "D:\DevPrograms\Anaconda3\lib\site-packages\conda\cli\main.py", line 111, in main_sourced
print(activator.execute(), end="")
UnicodeEncodeError: 'gbk' codec can't encode character '\ue1bb' in position 1523: illegal multibyte sequence
`$ D:\DevPrograms\Anaconda3\Scripts\conda-script.py shell.powershell activate base`
environment variables:
CIO_TEST=<not set>
CONDA_DEFAULT_ENV=vision
CONDA_EXE=D:\DevPrograms\Anaconda3\Scripts\conda.exe
CONDA_PREFIX=D:\DevPrograms\Anaconda3\envs\vision
CONDA_PROMPT_MODIFIER=(vision)
CONDA_ROOT=D:\DevPrograms\Anaconda3
CONDA_SHLVL=1
CURL_CA_BUNDLE=<not set>
GOPATH=C:\Users\David\go
HOMEPATH=\Users\David
PATH=D:\DevPrograms\Anaconda3\envs\vision;D:\DevPrograms\Anaconda3\envs\vis
ion\Library\mingw-w64\bin;D:\DevPrograms\Anaconda3\envs\vision\Library
\usr\bin;D:\DevPrograms\Anaconda3\envs\vision\Library\bin;D:\DevProgra
ms\Anaconda3\envs\vision\Scripts;D:\DevPrograms\Anaconda3\envs\vision\
bin;D:\DevPrograms\Anaconda3\condabin;C:\Program Files (x86)\Common Fi
les\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Sys
tem32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\Syste
m32\OpenSSH;D:\DevPrograms\mingw64\bin;D:\DevPrograms\apache-maven-3.8
.4\bin;D:\DevPrograms\Git;D:\DevPrograms\Git\bin;D:\DevPrograms\Git\cm
d;D:\DevPrograms\python37;D:\DevPrograms\python37\Scripts;D:\DevProgra
ms\Anaconda3\envs\python;D:\DevPrograms\Anaconda3\Scripts;D:\DevProgra
ms\Anaconda3\Library\bin;D:\DevSources\myProjects\MyScripts\bin;D:\Dev
Programs\Java\jdk1.8.0_301\bin;.;D:\mingw64\bin;D:\Neovim\bin;D:\Progr
am Files\SumatraPDF;C:\Program Files\dotnet;D:\Program
Files\texlive\2021\bin\win32;C:\Program Files\MySQL\MySQL Server
8.0\bin;D:\apache-maven-3.8.4\bin;C:\Program Files\MongoDB\Server\5.0\
bin;D:\DevPrograms\nodejs;D:\DevPrograms\Microsoft VS Code\bin;R:\MATL
AB\Polyspace\R2021a\runtime\win64;R:\MATLAB\Polyspace\R2021a\bin;R:\MA
TLAB\Polyspace\R2021a\polyspace\bin;D:\DevPrograms\PuTTY;D:\DevProgram
s\Java\jdk1.8.0_301;D:\DevPrograms\Java\jdk1.8.0_301\bin;D:\DevProgram
s\Java\jdk1.8.0_301\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW
S\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\
System32\OpenSSH;D:\Go\Go\bin;D:\Program Files
(x86)\Tencent\寰俊web寮€鍙戣€呭伐鍏穃dll;C:\Program Files\MySQL\MySQL Server 8
.0\bin;C:\Users\David\AppData\Local\Microsoft\WindowsApps;texlive\2021
\bin\win32;C:\Users\David\AppData\Local\GitHubDesktop\bin;D:\Program
Files\bandzip;C:\Users\David\AppData\Local\Programs\Microsoft VS
Code\bin;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.3\bin;.;C:\Us
ers\David\AppData\Roaming\npm;D:\DevPrograms\JetBrains\PyCharm
2021.3.3\bin;.;D:\Program Files
(x86)\Tencent\QQGameTempest\Hall.57795;C:\Users\David\go\bin
PSMODULEPATH=C:\Users\David\Documents\WindowsPowerShell\Modules;C:\Program Files\Wi
ndowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Mod
ules
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : vision
active env location : D:\DevPrograms\Anaconda3\envs\vision
shell level : 1
user config file : C:\Users\David\.condarc
populated config files : C:\Users\David\.condarc
conda version : 22.9.0
conda-build version : 3.22.0
python version : 3.9.7.final.0
virtual packages : __win=0=0
__archspec=1=x86_64
base environment : D:\DevPrograms\Anaconda3 (writable)
conda av data dir : D:\DevPrograms\Anaconda3\etc\conda
conda av metadata url : None
channel URLs : http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
package cache : D:\DevPrograms\Anaconda3\pkgs
C:\Users\David\.conda\pkgs
C:\Users\David\AppData\Local\conda\conda\pkgs
envs directories : D:\DevPrograms\Anaconda3\envs
C:\Users\David\.conda\envs
C:\Users\David\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/22.9.0 requests/2.25.1 CPython/3.9.7 Windows/10 Windows/10.0.22621
administrator : False
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
错误原因
这个错误看起来是与字符编码相关的问题,可能是由于终端在尝试将某个特殊字符以GBK编码写入输出时出现了问题。解决这个问题的方法通常是将终端的编码设置更改为支持更广泛字符集的编码,如UTF-8。
解决办法
-
更改PyCharm终端编码:
- 打开PyCharm。
- 转到 "File"(文件) > "Settings"(设置) > "Editor"(编辑器) > "Terminal"(终端)。
- 在 "Environment"(环境)部分,找到 "Environment variables"(环境变量)。
- 添加一个新的环境变量:
- 变量名:
PYTHONIOENCODING
- 变量值:
utf-8
- 变量名:
-
更改系统环境变量:
- 如果上述步骤没有解决问题,你可以尝试设置系统环境变量,以便整个系统使用UTF-8编码:
- 变量名:
PYTHONIOENCODING
- 变量值:
utf-8
- 变量名:
- 请注意,更改系统环境变量可能会影响其他应用程序,请谨慎操作。
- 如果上述步骤没有解决问题,你可以尝试设置系统环境变量,以便整个系统使用UTF-8编码:
总结
首先使用了方法2,未解决,然后使用方法1解决了该问题。
标签:bin,DevPrograms,mirrors,Anaconda3,illegal,sequence,multibyte,conda,tsinghua From: https://www.cnblogs.com/sonor/p/17663881.html