Python script in VS code using python standard library webbroswer works only while using debugger extension

Question:

I am using VS code, Visual code extension for debugging (showing the state of the code, putting marks where to run before running line by line and always showing the state of the parameters etc..) and I am trying to think how I should begin to check what is wrong if my codes with python standard library called webbrowser works only when I am using my debugger extension. My different short python scripts function if I run them while using the debugger extension but not while running them without the debugging extension. I have an example code which worked fine earlier but don’t work anymore.

The next code is an example which works if I have copied and address like "Tammiston kauppatie 10, 01510 Vantaa" (which is a Finnish street address to a climbing venue) and it is on my clipboard. This short script should take the address copied from the clipboard and open google maps site showing the address.

import webbrowser, sys, pyperclip


if len(sys.argv) >1:
    adress = " ".join(sys.argv[1:])
else:
    adress = pyperclip.paste()


webbrowser.open("https://www.google.com/maps/place/" + adress)

At the moment the code above doesn’t open my current webbrowser and doesn’t give any error messages either.

Any ideas how to make my code to work again? How to start checking what’s wrong?

Other maybe useful info:

[tool.poetry.dependencies]
python = "3.9.13"
requests = "^2.28.1"
pyperclip = "^1.8.2"
VS Code:
Version: 1.70.1 (user setup)
OS: Windows

The debugger extension says that it supports the codes with Python language: >=3.7

Also -> using Chrome, up to date version.

Asked By: Eriuth

||

Answers:

After going through the basics again with the help of JialeDu, I found that I had actually used Poetry wrong. I thought I had used "Poetry Run Python " as mentioned in the documentation (https://python-poetry.org/docs/basic-usage/#using-poetry-run) correctly few times and on different occasions (without it working), and other ways to run the code, but while going everything a new, this was the step that had failed. The Debugger extension used virtual environment correctly from the start. After running the files in my folder in different ways I continued debugging elsewhere. Now, after working this out, I can continue the debugging easily and make my scripts work where and how they should. Thank you for the lesson.

In a way: For me, the real answer for this problem is to start the debugging from the basics again and not really trusting that the basics where all checked the first few times correctly and start again still "few times more with the basics". I had actually moved too fast with my debugging and was thinking too broadly about all the possible ways the code to fail.

Answered By: Eriuth