@Denisca2828

Что же не так при компиляции в EXE кода Python?

Ошибка в коде :
from requests import get
import requests

ipp = get('https://api.ipify.org').text
ippp = str(ipp)
param = {'ip':ippp}
sett = requests.get('http://ip.kl.com.ua/index.php', params=param)

aaa = int(input("Введите первое число: "))
bbb = int(input("Введите второе число: "))
vid = input("Что будем делать(+, -, *, /): ")
plus = aaa + bbb
minus = aaa - bbb
umnoj = aaa * bbb
delen = aaa / bbb
if vid == "+":
	print("Ответ: " + str(plus))
if vid == "-":
	print("Ответ: " + str(minus))
if vid == "*":
	print("Ответ: " + str(umnoj))
if vid == "/":
	print("Ответ: " + str(delen))


Ошибка:
spoiler
D:\>pyinstaller -F main.py
854 INFO: PyInstaller: 3.5
854 INFO: Python: 3.8.0
854 INFO: Platform: Windows-10-10.0.18362-SP0
858 INFO: wrote D:\main.spec
862 INFO: UPX is not available.
886 INFO: Extending PYTHONPATH with paths
['D:\\', 'D:\\']
890 INFO: checking Analysis
890 INFO: Building Analysis because Analysis-00.toc is non existent
890 INFO: Initializing module dependency graph...
898 INFO: Initializing module graph hooks...
906 INFO: Analyzing base_library.zip ...
12633 INFO: running Analysis Analysis-00.toc
12655 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\denisca\appdata\local\programs\python\python38-32\python.exe
14478 INFO: Caching module hooks...
14498 INFO: Analyzing D:\main.py
14841 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
18414 INFO: Loading module hooks...
18414 INFO: Loading module hook "hook-certifi.py"...
18418 INFO: Loading module hook "hook-encodings.py"...
18580 INFO: Loading module hook "hook-pydoc.py"...
18584 INFO: Loading module hook "hook-xml.py"...
18748 INFO: Looking for ctypes DLLs
18753 INFO: Analyzing run-time hooks ...
18753 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
18904 INFO: Including run-time hook 'pyi_rth_certifi.py'
18920 INFO: Looking for dynamic libraries
23048 INFO: Looking for eggs
23048 INFO: Using Python library c:\users\denisca\appdata\local\programs\python\python38-32\python38.dll
23052 INFO: Found binding redirects:
[]
23379 INFO: Warnings written to D:\build\main\warn-main.txt
23531 INFO: Graph cross-reference written to D:\build\main\xref-main.html
23603 INFO: checking PYZ
23603 INFO: Building PYZ because PYZ-00.toc is non existent
23606 INFO: Building PYZ (ZlibArchive) D:\build\main\PYZ-00.pyz
Traceback (most recent call last):
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Denisca\AppData\Local\Programs\Python\Python38-32\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "D:\main.spec", line 18, in <module>
    pyz = PYZ(a.pure, a.zipped_data,
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
    self.__postinit__()
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
    self.code_dict = {
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code
    consts = tuple(
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 653, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "c:\users\denisca\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 660, in strip_paths_in_code
    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
  • Вопрос задан
  • 466 просмотров
Пригласить эксперта
Ответы на вопрос 2
bainy
@bainy
Ответ написан
Комментировать
@Alons
Я извиняюсь но как ты из экзешника собрался отвечать на импут? Интерфейс то у тебя не предусмотрен.
У меня получилось его скомпилить без особых проблем.
Но как я и сказал выше из за наличия импута он работать не будет.
На всякий случай держи скрипт. Все проще чем 100 раз через командную гонять.
'''

A preparation for creating exe files from scripts. You can use it as a standalone tool or wrap it in a function for mass conversion.

'''

 

import os

import shutil

import PyInstaller.__main__

 

exe_file_dir = r'C:\only_exe'

script_address = 'C:\\cri\\python\\test1.py'

 

PyInstaller.__main__.run([

    '--onefile',

    # '--noconsole',

    '--specpath', exe_file_dir,

    '--workpath', exe_file_dir,

    '--distpath', exe_file_dir,

    script_address

])

 

all_file_dir = os.listdir(exe_file_dir)

for file in all_file_dir:

    file_name, file_extension = os.path.splitext(file)

    if file_extension[1:].lower() != 'exe':

        path = exe_file_dir + '\\' + file

        if os.path.isfile(path):

            os.remove(path)  # remove the file

        elif os.path.isdir(path):

            shutil.rmtree(path)  # remove dir and all contains
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы