[Python] My code works when I run it by simply hitting the run button in Pycharm but not on...

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    #!/usr/bin/env python3

    # interact with command line, open a webpage, grab what you have in your clipboard
    import sys
    import webbrowser
    import pyperclip

    # function allowing us to open google maps page
    def print_addy(address):
    webbrowser.open(f'https://www.google.com/maps/place/{address}')
    # checking to see if we passed an argument on the terminal if not grab what's copied in clipboard
    if len(sys.argv) > 1:
    address = ' '.join(sys.argv[1:])
    else:
    # ## MODULENOTFOUND error in MAC CMD line, TypeError: missing argument in IED CMD line
    address = pyperclip.paste()

    # call the function
    print_addy(address)



    It works when I hit the run button and have an address copied or pass in an argument. However, when i try to run it on the Pycharm terminal with ./mapIt.py 123 random st

    I get


    TypeError: print_addy() missing 1 required positional argument: 'address'
    ​

    Why is it not recognizing the argument I'm passing?

    Continue reading...

Compartilhe esta Página