Python Forum
Pyinstaller, a problem with bundling py file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyinstaller, a problem with bundling py file
#7
In the meantime I removed os.py file that I had in the same folder. Now exe file from dist folder opens command line but it close it after a moment. I see first print statement and 200.

code:
#! python3
# lucky1.py - Opens several Google search results.
  
import webbrowser
import bs4 
import requests
import sys
 
def my_func(search_str):
    print('Googling...') # display text while downloading the Google page
    url = 'http://google.com/search?q=' + ' '.join(search_str)
    print(f'url: {url}')
    res = requests.get(url)
    print(res.status_code)
  
    # Retreive top search result links.
    soup = bs4.BeautifulSoup(res.text, "html.parser")
  
    # Open a browser tab for each result
    linkElems = soup.select('.r a')
    for link in linkElems:
        print(f'link: {link}')
    numOpen = min(5, len(linkElems))
    for i in range(numOpen):
        webbrowser.open('http://google.com' + linkElems[i].get('href'))
 
def test_it(args):
    print(args[1:])
    my_func(args[1:])
  
if __name__ == '__main__':
    test_it(sys.argv)
	

#! python3
# mapIt.py - Launches a map in the browser using an address from the
# command line or clipboard.

import webbrowser, sys, pyperclip
def my_func(get_add):
    if len(sys.argv) > 1:
	    # Get address from command line
	    address = ' '.join(get_add)
    else:
	    # Get address from clipboard
	    address = pyperclip.paste()

    webbrowser.open('https://www.google.com/maps/place/' + address)
	
def test_it(args):
	print(args[1:])
	my_func(args[1:])

if __name__ == '__main__':
	test_it(sys.argv)
	
...and for this code it opens google map immediately instead of letting user to write an address and then opens it ( at least that's how I understand this code ).

It looks that my codes are actually not designed to ask questions...If you have any advice what to look for please do.
Now I added input() but programs simply don't work after I add search term.
Reply


Messages In This Thread
RE: Pyinstaller, a problem with bundling py file - by Truman - Jul-28-2018, 10:51 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020