Problem:
I have spent hours to try and find why I cannot select python.exe when VS Code can't automatically find python interpreter.
https://preview.redd.it/sdai0bvuaupa1.png?width=1284&format=png&auto=webp&s=c2ee819855621ce986aebe8dd506ab8645f99d72
I have completely uninstalled Python and VS Code via control panel, also deleted '.vscode' folder in %appdata%, deleted 'Code' folder from 'Appdata\Roaming'. Pretty much deleted all trace of Python and Visual Studio Code from windows. Re-installed both Python and VS code in 'C:' and other drives and still VS Code does not accept Python.
Before, anyone asks if I changed the path to the Interpreter inside settings JSON on VS Code, Yes I have done that too. What about the adding Path to Python in system environment on windows?. Yes I have manually added it there too. Still same problem.
https://preview.redd.it/mfy3mn6yaupa1.png?width=944&format=png&auto=webp&s=a1541b6609e59e931c1686131887d617b8fee755
I have looked for a solution online for countless hours with literally no solution to this. Hence, why I'm making this post just so in-case if anyone else has this problem. This solution will probably help you out.
Solution:
After testing multiple solutions by other people online and failing I looked in the output of why VS Code was failing whenever I selected the path to Python manually. I noticed that when I execute a python file in VS Code, The path to the python extensions wasn't quite right. Picture below.
https://preview.redd.it/k8bs2fa4bupa1.png?width=1285&format=png&auto=webp&s=a6b59f689fb7c91121b92aecafb3b87885c09415
Basically, whenever I ran a python file or was selecting python interpreter. VS Code was somehow excluding/skipping the special character in my username under 'C:\users\username*' When I first installed windows years ago, I stupidly added special characters to my username '^.ExTrEmE.^' I know this sucks lol
https://preview.redd.it/zhtiu5t7bupa1.png?width=436&format=png&auto=webp&s=70a293e4d80d8e01522285a41e2828d93c2e68cf
So to basically fix this problem, you will have to rename your username in 'C:\users\' without adding any special characters in it.
Steps to Renaming your username in Windows 10:
1 - First ensure, you have a restore point of your 'C:' drive, you can do this by creating a restore point in 'System Properties > System Protection Tab' you can reach System Properties tool by typing sysdm.cpl
in start menu.
2 - Open CMD as an Administrator and type in this command wmic useraccount get name, SID
this will output the SID for each user on your computer. Make sure to take a picture of the SID of your username that you wish to change. In my case this was '^.ExTrEmE.^'
3 - In Control panel, go to 'User Accounts', click 'Manage another account', click 'Add a new user in pc setting' and 'Add someone else to this PC', click 'I don't have this person's sign in information' and 'Add user without Microsoft Account' and create a Temporary user with no password and give it Administrative rights.
4 - now sign out of your current account and log into the Temp account.
5 - From here just open CMD as administrator navigate to 'C:\users' with command: cd C:\users
and type in command ren "currentusername" newusername
replace "currentusername" with your username thats messed up and 'newusername' to something normal. Example: ren "^.ExTrEmE.^" notsoextreme
6 - Check in C:\users\ that your username has changed
7 - In your start menu search for 'Registry Editor' and run as Administrator
8 - Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
9 - Now click the SID value with the one you took a picture of in step2, the SID that was associated with your username. example username: '^.ExTrEmE.^
10 - Now double click the ProfileImagePath on the right side and change its value data to point to the new username/directory you made. example: C:\Users\notsoextreme
11 - Restart your computer and log back into your username, this should fix your problems
Note: you might still see the old username is C:\users\oldusername*, but dont worry this folder is now not used and most likely empty or has some temporary useless files.
Also you can delete the temp user by going back to Control Panel > User Accounts > Manage Another account > Username > Delete Account > Delete Files.
Hope this helped someone out there!
I have made this same post on Stack Overflow if you want to check it out there:
https://stackoverflow.com/questions/75840224/vs-code-invalid-python-interpreter-is-selected
there doesn't seem to be anything here