Skip to content

Path translation when using WSL bash in integrated terminal  #40

Closed

Description

@ricek

Environment data

VS Code version: 1.18.0
Python Extension version: 0.8.0
Python Version: 3.6.3
OS and version: Windows 10 v1709 build 16299.19

Actual behavior

/usr/bin/python3 d:/Web/test.py

Expected behavior

/usr/bin/python3 /mnt/d/Web/test.py

Steps to reproduce:

  • In settings.json, add WSL and set python path to the one installed on WSL
  • "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"
  • "python.pythonPath": "/usr/bin/python3"
  • Run Python File in Terminal

Logs

Output from Python output panel

/usr/bin/python3: can't open file 'd:/Web/test.py': [Errno 2] No such file or directory

Activity

  1. ricek commented on Nov 11, 2017

    @ricek
    Author

    I was able to use a bat script to work around

    python3.bat

    @echo off
    set v_params=%*
    set v_params=%v_params:\=/%
    set v_params=%v_params:c:=/mnt/c%
    set v_params=%v_params:"=\"%
    bash.exe -c "python3 %v_params%"
    

    Changed settings.json to use cmd as the integrated terminal and point the path to the bat script
    "python.pythonPath": "C:\\path\\to\\bat\\python3"

    VSC finally able to Run Python File in Terminal but still warn me about to Select Python Environment

    Based off above script, I created another one for pycodestyle and attempt to change "python.linting.pep8Path": "C:\\path\\to\bat\\pycodestyle" which should point to the pycodestyle installed on WSL bash but I ran into linting error as follow:

    Output from Python output panel

    ----------Generating Tags----------
    ctags --options=C:\Users\Liang\.vscode\extensions\ms-python.python-0.8.0\resources\ctagOptions --languages=Python --exclude=**/site-packages/** -o c:\code\.vscode\tags .
    
    Linting with pep8 failed.
    You could either install the 'pep8' linter or turn it off in setings.json via "python.linting.pep8Enabled = false".
    Error: spawn pycodestyle ENOENT
    

    From Troubleshooting linting, I can confirm pythonPath setting is correct since the python3.bat script executed without error and the linter was already installed under the current python3 environment in WSL bash.

    However, if I installed pycodestyle via Windows pip, pep 8 linting runs just as expected.

  2. helioascorreia commented on Nov 12, 2017

    @helioascorreia

    It would be awesome to have support for wsl on python

  3. brettcannon commented on Nov 14, 2017

    @brettcannon
    Member

    Closing as a duplicate of #67

  4. liusanye commented on Feb 16, 2018

    @liusanye

    How to make vscode debug call wsl python

  5. DonJayamanne commented on Feb 16, 2018

    @DonJayamanne

    liusanye (@liusanye) please check #67 (this is not yet supported)

  6. locked as resolved and limited conversation to collaborators on Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions