V
V
Vasiliy_Ivanov2021-12-03 22:18:12
Python
Vasiliy_Ivanov, 2021-12-03 22:18:12

Error while working with the requests library, what should I do?

Good day! I decided to make a program that downloads an mp3 file to get acquainted with requests.
Everything works fine with the .py extension, but after "remaking" it into an exe file, it gives an error: 61aa6b97d25e6454642391.png

I use pyinstaller to create an exe file:
pyinstaller -F main.py

Here is the entire simple code (I repeat with the .py extension, everything works fine):

import requests
import os

req = requests.get('Сыллка на файл', stream=True)

if not os.path.exists('music.mp3'):
    with open('music.mp3', 'wb') as file_mp3:
        file_mp3.write(req.content)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andy_U, 2021-12-03
@Andy_U

Here, it was worth publishing the protocol and clarity increased. See the penultimate line in the protocol. Read what sys._MEIPASS is. This is the directory where the files that lay next to the original script and that were specified in the Analysis(binaries=...) parameter in the spec file are found to be included in the generated exe file. In your case, not listed. I'm talking about the cert.pem certificate. Or certifi/cacert.pem? But since you didn’t provide a minimal example where the error is reproduced, you can figure it out yourself further.
PS Just today there was an example of how to use it: https://qna.habr.com/q/1083572

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question