question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry changes sys.argv[0]?

See original GitHub issue
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

Hi. For the help menus in my CLI scripts, I like to print usage instructions like this:

print("Usage:")
print("    "+sys.argv[0]+" <command> [options]")

But Poetry seems to change sys.argv[0] to the full path of the script, instead of keeping what the user actually typed in. Why? Is there any way around this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
probablykaspercommented, Oct 7, 2018

@fridex That doesn’t really fix the problem. If the user did type in the full path with that code, he would only get the basename.

0reactions
finswimmercommented, Jul 1, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry: conflicting imports - python - Stack Overflow
It looks like after any change in project structure one has to run $ poetry install. again.
Read more >
EnvCommandError - cannot get django tutorial to deploy
I created an environment variable to get render to use python 3.8.2 ... file is not up to date with the latest changes...
Read more >
A Python program can be outside of a virtual environment it uses
For years, I thought that activating a virtualenv was changing the PATH (so I would get the right binaries in my shell) and...
Read more >
poetry script fails to find module - Google Groups
In the poetry shell sys.path has this additional path ... but mainly in honour of a classic dad-joke, I changed 'stoat' to 'weasel'....
Read more >
How to use sys.argv in Python - GeeksforGeeks
print ( "This is the name of the program:" , sys.argv[ 0 ]). print ( "Argument List:" , str (sys.argv)). Output: sys.argv.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found