我正在尝试使其能够从WSL执行Windows anaconda的conda命令。但是,由于未设置正确的路径变量,因此无法连接。
其中别名仅在bashrc中定义为:
CONDA_PATH=/mnt/c/Users/spong/Anaconda3
alias conda="$CONDA_PATH/Scripts/conda.exe"
在
中执行结果michael@DESKTOP-OI3AOU6:~$ conda update conda
Collecting package metadata: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anacon
da.com/pkgs/free/win-64/repodata.json.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on
your way.
If your current network has https://www.anaconda.com blocked, please fi
le
a support request with your network engineering team.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\',
port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.j
son.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SS
L module is not available."))'))
我了解到conda.exe起作用的路径中必须包含某些路径:
我不想让这些目录一直位于我的路径中,因此我临时设置了以下路径:
CONDA_PATH=/mnt/c/Users/spong/Anaconda3
PATH_APPENDS=$CONDA_PATH:$CONDA_PATH/Library/mingw-w64/bin:$CONDA_PATH
/Library/bin:$CONDA_PATH/Scripts
alias conda="PATH=$PATH:$PATH_APPENDS conda.exe"
这会导致错误消息:
michael@DESKTOP-OI3AOU6:~$ conda
-bash: syntax error near unexpected token `('
这是总路径:
michael@DESKTOP-OI3AOU6:~$ echo $PATH:$PATH_APPENDS /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/Microsoft MPI/Bin:/mnt/c/VulkanSDK/1.1.101.0/Bin:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/mnt/c/MinGW/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/dotnet:/mnt/c/Users/spong/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/spong/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/texlive/2018/bin/win32:/mnt/c/Users/spong/bin:/snap/bin:/home/michael/.cargo/bin:/mnt/c/Users/spong/Anaconda3:/mnt/c/Users/spong/Anaconda3/Library/mingw-w64/bin:/mnt/c/Users/spong/Anaconda3/Library/bin:/mnt/c/Users/spong/Anaconda3/Scripts
所以由于某种原因,路径中带上的括号现在已成为问题。
这是我的.bashrc上的部分
## Conda Aliases # Adding conda as an alias to the anaconda installation in the home dir # Conda requires the following path to function: # Anaconda3/ # Anaconda3/Library/mingw-w64/bin # Anaconda3/Library/bin # Anaconda3/Scripts CONDA_PATH=/mnt/c/Users/spong/Anaconda3 PATH_APPENDS=$CONDA_PATH:$CONDA_PATH/Library/mingw-w64/bin:$CONDA_PATH /Library/bin:$CONDA_PATH/Scripts alias conda="PATH=$PATH:$PATH_APPENDS conda.exe" #alias conda="$CONDA_PATH/Scripts/conda.exe" alias conda-cheatsheet="\$(cd $CONDA_PATH;mupdf.exe conda-cheatsheet.pd f)" alias ipython="$CONDA_PATH/Scripts/ipython3.exe" alias jupyter-notebook="$CONDA_PATH/Scripts/jupyter-notebook.exe --no-b rowser" alias anaconda-navigator="$CONDA_PATH/Scripts/anaconda-navigator.exe"
type conda
的输出:
michael@DESKTOP-OI3AOU6:/mnt/c/Windows/System32$ type conda
conda is aliased to `PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/Microsoft MPI/Bin:/mnt/c/VulkanSDK/1.1.101.0/Bin:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/mnt/c/MinGW/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/dotnet:/mnt/c/Users/spong/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/spong/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/texlive/2018/bin/win32:/mnt/c/Users/spong/bin:/snap/bin:/home/michael/.cargo/bin:/mnt/c/Users/spong/Anaconda3:/mnt/c/Users/spong/Anaconda3/Library/mingw-w64/bin:/mnt/c/Users/spong/Anaconda3/Library/bin:/mnt/c/Users/spong/Anaconda3/Scripts" /mnt/c/Users/spong/Anaconda3/Scripts/conda.exe'
答案 0 :(得分:0)
PATH的此部分中的括号可能是导致问题的原因
:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:
在定义别名时尝试添加反斜杠转义的双引号:
alias conda="PATH=\"$PATH:$PATH_APPENDS\" conda.exe"