0

I'm embarrassed to ask this, because I consider myself a seasoned programmer in general and with Python in particular (albeit mostly on Linux), but I just can't seem to get VSCode and Python working together. This is all on Windows 10.

I seem to have both installed. I've done my best to follow instructions at https://learn.microsoft.com/en-us/windows/python/beginners and I can start python as "python" or "python3", see that it's version 3.9.6, and can get it to say "Hello World!". However, I cannot follow instructions to start python as "py" because it reports no such animal.

I have VSCode. It says I have "Python for VSCode" when I list Extensions.

But the stopper is that a few steps into the instructions at https://code.visualstudio.com/docs/python/python-tutorial#_start-vs-code-in-a-project-workspace-folder i get stuck because when I attempt to select a Python interpreter, it says there is no such.

I've tried a bunch of stuff, but since it's not clear what's wrong or missing, it's hard to know if I've tried everything. Except that clearly I haven't.

Can someone guide me a bit?

ForDummies
  • 151
  • 1
  • 2
  • 9
  • Trying... it looks like something I'd use after I got python running, in order to support different versions. I say that because it points to a link as a prerequisite and that's the one I'm stumbling over. – ForDummies Jul 19 '21 at 20:33
  • Well, there should be information there on how to discover the interpreter locations, which is basically what you need to tell VScode. Also, `py` is just a special launcher for windows, it isn't strictly necessary... I'm not sure if I'm telling you something you already know or not. [Here is some more info](https://stackoverflow.com/questions/50896496/what-is-the-difference-between-py-and-python-in-the-terminal) generally, I would probably just work with virtual environments, even `conda`. But I don't use Windows. – juanpa.arrivillaga Jul 19 '21 at 20:35
  • Tried the link you sent even harder. More stumbling blocks. In the VSCode terminal it says I can use "py -0" to discover Python versions. But for me, it actially reports that "py" is not recognized as a cmdlet, function, script file, or operable program. And "python -0" reports that "-0" is not a recognized option. I'm still stuck. – ForDummies Jul 19 '21 at 20:49
  • Well, you should just be able to do whatever the equivalent of `which python` is on windows in your terminal. I believe there is always a default interpreter for vscode anyway. In any case, adding as many details to the question itself would help get this question more traction. – juanpa.arrivillaga Jul 19 '21 at 20:50
  • well, "which" is a Unix/Linux thing. "py -0" was supposed to do that on Windows VSCode, but doesn't. And as for details, I have no idea what to add because I don't yet know very much. – ForDummies Jul 19 '21 at 20:53
  • A quick google search led me to suggest to try `where python` in your terminal. Again, sorry, not a Windows user aside from video games. – juanpa.arrivillaga Jul 19 '21 at 20:54
  • 1
    Thanks. That answers C:\Users\\AppData\Local\Microsoft\WindowsApps\python.exe which tells me I installed it only for me. Is that a problem? I could install it globally, I suppose, and lacking any other ideas, I'll try that next. – ForDummies Jul 19 '21 at 20:57
  • Yeah, thanks for help. I'm a WIndows user in many ways, but most of my long years of programming have been in other environments -- assembler, *Nix, and others. – ForDummies Jul 19 '21 at 21:00
  • No it shouldn't be, but again, I **highly** suggest you use virtual environments, [here is a good primer](https://realpython.com/python-virtual-environments-a-primer/). I personally really like [`conda`](https://docs.conda.io/projects/conda/en/latest/). But you can use the standard library [venv](https://docs.python.org/3/library/venv.html) or probably better yet the third-party (but popular) [virtualenv](https://virtualenv.pypa.io/en/latest/). Conda is particularly geared towards the scientific/data python stack (numpy, pandas etc) – juanpa.arrivillaga Jul 19 '21 at 21:02
  • But maybe it did. I just uninstalled Python, then installed from python.org, and now 'py' and 'py -0' do what the tutorials said they should do. I'm about to try to proceed. – ForDummies Jul 19 '21 at 21:37
  • No such luck. I am a little further along, but only a little. In the VSCode tutorial https://code.visualstudio.com/docs/python/python-tutorial, I'm still stuck at "Select a Python Interpreter". Although I can use a terminal to start Python, and "py -0" shows one interpreter, marked with the "*" that says it's the default, the instructions stop making sense when I can't see what they expect me to see:: "Python Select Interpreter" does not match anything -- not even just the "Pyth" prefix matches anything. Trying to skip to the mext step is even worse. – ForDummies Jul 19 '21 at 23:15
  • I can also coax VSCode into editing and saving a hello.py file, with the indicated contents, but I do NOT see the "terminal play button" in the top right side of the editor. That siad, there's enough for me to limp along. VSCode sees and can edit my Python Code. Either the Command Prompt (from the Search in Start) or a pwershell from VSCode or the start menu can execute "python hello.py" just fine. That will get me started, but it sure feels awkward not to be able to use the integration promised by the documentation. – ForDummies Jul 19 '21 at 23:36

0 Answers0