Can't get started with VSCode and Python 3.9 - python

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?

Related

try/except block and ctrl-d/EOFError

I'm trying to learn Python.
I'm using Windows 10 on a desktop PC.
I initially went through University of Michigan's 'Python for Everyone' on the edx.org platform. For that I used the Atom editor and installed Python from www.python.org
Installed version of Python is 3.10.4.
I then uninstalled Python and Atom and installed Anaconda/Spyder. The reason for doing this was that I wanted to make use of the tools from JPL/NASA for calculating and visualizing orbits (as in orbital mechanics; search for 'AWP orbital' on Youtube, you'll see what I wanted to do). I tried initially to install the required libraries, but as I had read in a post on this site, attempting to do this in Windows 10 will probably not work, so the recommendation was to use Anaconda as it comes with literally everything. So after switching to Anaconda, I was able to run the samples that that Youtuber provided in his github, but I didn't understand enough to do anything else with it.
So, having realized that I'm in way over my head, still need to do more basic stuff in Python. I'm 47 so this stuff doesn't come easy to me. No prior programming experience other than messing around with C a bit in uni 20+ years ago to do number crunching.
Sorry for rambling on... in any case, now I'm going through the Harvard CS50 Introduction to Programming with Python on edx.org and I uninstalled Anaconda and went back to Atom and installed Python from python.org like the first time around.
Finally I'm getting to the question. Before installing Anaconda, when I used cmd or the powershell, I could use the ctrl-d to get the EOFError in a try/except block of code, but now when I use either cmd or powershell, ctrl-d just displays ^D but doesn't actually execute the break that I have after my except statement. I tried changing it to ctrl-c and changing the except to KeyboardInterrupt, and that does execute the break, but it seems it doesn't work quite the same way. It would seem that having switched to Anaconda and then back to a basic install from python.org is what caused this ctrl-d to not work anymore, but I don't have a clue as to what I need to do to restore this functionality.
Any ideas?

VS Code is unable to locate python

I have been looking at similar problems and everyone has a promising solution which usually revolves around changing the interpreter path. I have done my best but have run out of solutions that I can think of. I'm hoping someone else knows how and thank you for any comments.
No version of python ever appears, I have tried to enter the path in the box at the top but have had no luck
I want to switch from 3.10 to 3.9 and this is when not being able to select the version of python became a problem. The picture above is from the terminal within VS Code
This is the default path I have entered in VS Code
The photo above is from the Windows command prompt, locating the active version of python
I would like to be able to use Python 3.10 in some folders and 3.9 in others, however at the moment I really just need VS Code to see 3.9, I imagine once I know what has gone wrong at this stage it will be smooth sailing from here.
I have already uninstalled and reinstalled pretty much anything I can think could be related
I really hope I have just made a stupid mistake somewhere and it is really obvious, thank you again

Strange path when compiling python in VsCode

everyone. I've been using python for a while with PyCharm, however I decided to go back on VsCode because I'm used to it.
I installed the python extension, specified the interpreter and compiled a basic file. Everything seems ok, except a strange path in the terminal which is annoying.
When I compile JavaScript it specifies the path rather simple:
C:\Program Files\nodejs\node.exe tests.js
However when I compile python it is a lot bigger:
PS D:\Projects\> ${env:DEBUGPY_LAUNCHER_PORT}='12345'; & 'C:\Users\user1\AppData\Local\Programs\Python
\Python38-32\python.exe' 'c:\Users\user1\.vscode\extensions\ms-python.python-2020.4.76186\pythonFiles
\lib\python\debugpy\no_wheels\debugpy\launcher' 'd:\Projects\app.py'
My question is, is this normal and is there a way to remove it or should I get comfortable with.
Two things. One, that's not compiling your code, it's running your code under the the debugger. Python doesn't really have a compiler step in the traditional sense.
Two, there isn't anything you can do about it. It's how the debugger launches.

How can I get gcalcli to work on Python 36?

Old-time user, first-time asker here,
I am very new to Python, and I started by downloading Anaconda with Pyhon 3.6. I tried to get gcalcli to work, but it's having big Python version conflicts. It looks like gcalcli was made for Python 2, but then my "default" Python is 3. Many of the modules gcacli needs have also been installed for Python 3. I think that even the print command has changed between the two versions.
I believe I have all the necessary modules installed: Google API Client, dateutil, gflag, but their versions might be part of the problem.
I can run gcalcli from Python 2 (by changing the first line in the gcalcli file) but it will crash when a Python 3 module is needed and the syntax is strange. I also tried running gcacli from Python 3, but the same happens when it runs into syntax that only works for Python 2.
I tried copying the content in the Python36/Lib folders to Python27/Lib, and run gcalcli from Python 2. That helped the program run a bit further, until it ran into another incompatible bit of syntax. In other words, I'm kinda trapped in version hell.
Has anyone found a solution for this kind of version and script/module compatibility problem?
Thank you, very much.

How to install openCV 3.x for use with python 3.x in Windows 10

Can someone please provide a 'for dummies' list of instructions to install openCV 3.x for use with Python 3.x on Windows 10?
A Hello-World of sorts? The OpenCV site doesn't appear to have one.
I am happy to use whatever IDE but as I have used Sublime Text 2 I would prefer to keep doing so.
I have spent quite a bit of time developing a reasonably complex and succesful C++ 2.x openCV application in Visual Studio and managed (with some effort) to get that development environment working for me, but when it comes to cmake/builds/github/source/compilers and all the configurations required for Python I am facing too many free variables and unknowns (and my own ignorance regarding these things).
In all the tutorials, SE Q&A and other internet dialog I've discovered there is jargon heavy and includes missed steps and assumed knowledge.
Potentially irrelevant info (??) follows:
OpenCV for Python 3.x under Windows looks good, but cmake is complaining:
"CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set."
Which is probably something to do with my selection of 'Sublime Text 2 - minGW' in 'configure'. Maybe not, no idea, the answer given doesn't suggest which option I'm meant to chose and why...

Categories

Resources