I can enter into my terminal (wsl) python3 filename.py and the code executes in the terminal just fine. But when I hit the play button (Run Python File) I get errors
C:/Users/user1/AppData/Local/Programs/Python/Python311/python.exe "c:/Online Learning/Coder Academy/Python/Lesson-3/test.py" zsh: no such file or directory: C:/Users/user1/AppData/Local/Programs/Python/Python311/python.exe
I don't see why if the code is executing fine from the terminal by typing in the command. Why can't I hit the play button without error?
I've tried a lot of things including using extension Code-Runner. Uninstalling and re-installing various versions of python. I've tried pyenv, defining various different interpreter paths.
I'm thinking it's not the set up of my python in wsl it's something to do with a setting in VSCode.
CodePudding user response:
I'm not totally sure, but it seems to be coughing up that "python.exe" doesn't exist. What I remember doing is checking if "py.exe" works and see if the problem is resolved. If so, go to where VSCode says Python is and copy py.exe to your desktop, rename it to python.exe and paste it back to the folder where py.exe was. It may not be good practice, but was my workaround. I guess the best thing to do is just to reinstall Python.
CodePudding user response:
I would agree with the setting in vscode.
hitting cntrl shift p, type python, hit 'select' interpreter will let you pinpoint exactly where vscode thinks the interpreter is.
For many reasons I would strongly recommend using a virtual env. For the purposes of this discussion, you know that you'll be creating a folder that has a version of python in it that you can select.
Best of luck. these issues can be very frustrating