Search code examples
pythonpython-3.xgoogle-apiexegoogle-books

Python executable file closes without showing outputs


I created a code that use Google Books API on Jupiter in python language. I would like to create an .exe file in order to use it on other PCs. I did it with pyinstaller name_of_the_script.py, but when I execute it after I entered the second input, the command window disappears without showing outputs, also if I put an input line at the end in order to keep alive the script until I press a key.

Here the code:

import requests

quote = input('Inserisci la citazione: ')
lingua = input('\nInserisci lingua (sigla, ad esempio ''it'' per ''Italiano''): ')


key = 'xxxxxxxxx'
parms = {'q':quote, 'key':key, 'maxResults':5,'langRestrict':lingua}

r = requests.get(url='https://www.googleapis.com/books/v1/volumes', params = parms)
rj = r.json()

for i in range(0,3):
    print('\n' + rj['items'][i]['volumeInfo']['title'] + '\n')
    for authors in rj['items'][i]['volumeInfo']['authors']:
        print(authors)
    print('\n' + '\n')

input('press enter to quit')

What is wrong?


Solution

  • I solved!

    It was an error in the conversion of the .ipynb file into .py file. To convert it I used a code found here in SO and now it works.

    Here the post that helped me:

    Is it possible to generate an executable (.exe) in a jupyter-notebook?