当使用 WSL python 解释器时,Pycharm 会尝试到cd
项目的 Source 根文件夹。但是它使用的是完整的 Windows 路径:\\wsl$\Ubuntu-18.04\home\ubuntu\code\my-repo
而不是所需的 WSL 路径:~/code/my-repo
导致以下错误:
C:\Users\user\AppData\Local\Microsoft\WindowsApps\ubuntu1804.exe run "export PYTHONUNBUFFERED=1 && export PYTHONIOENCODING=UTF-8 && export PYTHONPATH=\\wsl$\Ubuntu-18.04\home\ubuntu\code\my-repo:/mnt/c/Users/user/AppData/Local/JetBrains/Toolbox/apps/PyCharm-P/ch-0/202.6397.98/plugins/python/helpers/pycharm_matplotlib_backend:/mnt/c/Users/user/AppData/Local/JetBrains/Toolbox/apps/PyCharm-P/ch-0/202.6397.98/plugins/python/helpers/pycharm_display && export PYCHARM_HOSTED=1 && export PYCHARM_DISPLAY_PORT=63342 && cd \\wsl$\Ubuntu-18.04\home\ubuntu\code\my-repo && /home/ubuntu/code/my-repo/venv/bin/python '//wsl$/Ubuntu-18.04/home/ubuntu/code/my-repo/code.py'"
/bin/bash: line 0: cd: \wsl$Ubuntu-18.04homeubuntucodemy-repo: No such file or directory
Pycharm 专业版 2020.2