0

I have question about vscode, venv and code runner

My setting looks like:

"python.pythonPath": "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
"code-runner.executorMap": { "python": "$pythonPath -u $fullFileName " }

as select interpreter I use ./venv/bin/python

and on Terminal everything works

but ctrl+alt+N in OUTPUT I get: /bin/sh: /Users/me/Documents/Visual: No such file or directory

and should be

/Users/me/Documents/Visual Studio Code/MyProject/venv/bin/python

when I change to /Users/me/Documents/VisualStudioCode/MyProject/venv/bin/python it works!!!

Is possible to configure python to use full path with spaces???

Thanks a lot

Tomasz

PS

what mean here -u?

("$pythonPath -u $fullFileName ") 
19
  • @Ophir have You edited my qestion? I mean sugestion for formating my qestion or is it automatic? Commented May 17, 2020 at 10:03
  • it is problem with system, not Python. If you use spaces then you have to put path in " " or ' ' or you have to use \ before every space in name. BTW: Spaces always made problem in path and filename so older programmes never used spaces in names. The same problem made native chars - ąęść. Commented May 17, 2020 at 10:46
  • BTW: run python --help and you will see what means -u Commented May 17, 2020 at 10:47
  • @furas OK but where I should add the "" '' or \ ??? look please for my settings Commented May 17, 2020 at 10:49
  • around path inside your string - see ' ' in "$pythonPath -u '$fullFileName'" or \" \" in "$pythonPath -u \"$fullFileName\"" Commented May 17, 2020 at 10:50

1 Answer 1

1

I found the solution:

"code-runner.executorMap": {"python": "\"$pythonPath\" -u $fullFileName"}
Sign up to request clarification or add additional context in comments.

6 Comments

BTW: you can also use " " inside ' ' - ' "$pythonPath" -u $fullFileName' . Normally you can use also ' ' inside " " but shell/bash may tread '$pythonPath' as normal string and not replace $pythonPath with value.
@furas and it is very strange that on windows You should add ' ' here: '$fullFileName' and on mac '$pythonPath'
to make sure I would add ' ' on both '$fullFileName' and '$pythonPath'. But I always try to use paths without spaces and native (Polish) chars.
@furas It is not easy do like this If you have path eg, Users/Adam/My Documents/Python/ThisProject it doesn't work becouse error is on My Documents
do you have problem when you put it in " " inside ' ' - ' "$pythonPath" -u "$fullFileName" ' ? It should create string "/path/to/python" -u "Users/Adam/My Documents/Python/ThisProject" and it should work in bash/shell. If variables are replaced by VS (not bash/shell) then should work also ' ' inside " " - " '$pythonPath' -u '$fullFileName' " and it should create string '/path/to/python' -u 'Users/Adam/My Documents/Python/ThisProject' and it should also work in bash/shell.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.