Typeerror an integer is required got type bytes pyinstaller как исправить

When i compile any script using pyinstaller i get TypeError: an integer is required (got type bytes) i tried both with and without UPX, still the same error, i even tried installing the latest dev ...

xception ignored in thread started by: <function check_errors..wrapper at 0x7f96f302bd30>
Traceback (most recent call last):
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/utils/autoreload.py», line 225, in wrapper
fn(*args, **kwargs)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py», line 117, in inner_run
self.check(display_num_errors=True)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/management/base.py», line 376, in check
all_issues = self._run_checks(
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/management/base.py», line 366, in _run_checks
return checks.run_checks(**kwargs)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/checks/registry.py», line 71, in run_checks
new_errors = check(app_configs=app_configs)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/checks/urls.py», line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/core/checks/urls.py», line 57, in _load_all_namespaces
url_patterns = getattr(resolver, ‘url_patterns’, [])
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/utils/functional.py», line 37, in get
res = instance.dict[self.name] = self.func(instance)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/urls/resolvers.py», line 533, in url_patterns
patterns = getattr(self.urlconf_module, «urlpatterns», self.urlconf_module)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/utils/functional.py», line 37, in get
res = instance.dict[self.name] = self.func(instance)
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/django/urls/resolvers.py», line 526, in urlconf_module
return import_module(self.urlconf_name)
File «/Users/rhandall/opt/anaconda3/lib/python3.8/importlib/init.py», line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File «», line 1014, in _gcd_import
File «», line 991, in _find_and_load
File «», line 975, in _find_and_load_unlocked
File «», line 671, in _load_unlocked
File «», line 783, in exec_module
File «», line 219, in _call_with_frames_removed
File «/Users/rhandall/Documents/GitHub/school_new/base/urls.py», line 5, in
from schoolio import views as schoolio_views
File «/Users/rhandall/Documents/GitHub/school_new/schoolio/views.py», line 81, in
from .standard_matching import match_standard, match_activity, fetch_single_classroom, match_standard_to_international
File «/Users/rhandall/Documents/GitHub/school_new/schoolio/standard_matching.py», line 1, in
from sklearn.feature_extraction.text import CountVectorizer
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/sklearn/init.py», line 80, in
from .base import clone
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/sklearn/base.py», line 21, in
from .utils import _IS_32BIT
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/sklearn/utils/init.py», line 23, in
from .class_weight import compute_class_weight, compute_sample_weight
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/sklearn/utils/class_weight.py», line 7, in
from .validation import _deprecate_positional_args
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/sklearn/utils/validation.py», line 21, in
import joblib
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/init.py», line 119, in
from .parallel import Parallel
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/parallel.py», line 28, in
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/_parallel_backends.py», line 22, in
from .executor import get_memmapping_executor
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/executor.py», line 14, in
from .externals.loky.reusable_executor import get_reusable_executor
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/externals/loky/init.py», line 12, in
from .backend.reduction import set_loky_pickler
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/externals/loky/backend/reduction.py», line 125, in
from joblib.externals import cloudpickle # noqa: F401
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/externals/cloudpickle/init.py», line 3, in
from .cloudpickle import *
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/externals/cloudpickle/cloudpickle.py», line 152, in
_cell_set_template_code = _make_cell_set_template_code()
File «/Users/rhandall/Documents/GitHub/school_new/venv/lib/python3.8/site-packages/joblib/externals/cloudpickle/cloudpickle.py», line 133, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)

Need Help with this anyone please

01.12.2019, 16:36. Показов 8502. Ответов 1


Доброго дня..

В первый раз пытаюсь собрат приложение в PyCharm (python 3.8)

pyinstaller -F -w -i «C:pythonSortSort.ico» sor.py

версия pyinstaller 3,5

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
import tkinter.ttk as ttk
import os
from datetime import datetime
 
root = Tk()
root.title('PhotoSort')
root.iconbitmap('Sort.ico')
root.geometry('500x150+1000+300')
s = ttk.Style()
s.configure('my.TButton', font=("Pixel Cyr", 15))
 
 
def choose_dir():
    dir_path = filedialog.askdirectory()
    e_path.delete(0, END)
    e_path.insert(0, dir_path)
 
def f_start():
    cur_path = e_path.get()
    if cur_path:
        for folder, subfolders, files in os.walk(cur_path):
            for file in files:
                path = os.path.join(folder, file)
                mtime = os.path.getmtime(path)
                date = datetime.fromtimestamp(mtime)
                date = date.strftime('%Y-%m-%d')
                date_folder = os.path.join(cur_path, date)
                if not os.path.exists(date_folder):
                    os.mkdir(date_folder)
                os.rename(path, os.path.join(date_folder, file))
        messagebox.showinfo('Success', 'Сортировка завершена')
        e_path.delete(0, END)
    else:
        messagebox.showwarning('Warning', 'Выберите папку с файлами')
 
 
frame = Frame(root, bd=5) #bg='#002B36'
frame.pack(pady=10, padx=10, fill=X)
 
e_path = ttk.Entry(frame)
e_path.pack(side=LEFT, ipady=2, expand=True, fill=X)
 
btn_dialog = ttk.Button(frame, text='Выбрать папку', command=choose_dir)
btn_dialog.pack(side=LEFT, padx=6)
 
btn_start = ttk.Button(root, text="START", style="my.TButton", command=f_start)
btn_start.pack(fill=X, padx=10)
 
root.mainloop()
'''

(venv) C:pythonSort>pyinstaller -F -w -i «C:pythonSortSort.ico» sort.py
92 INFO: PyInstaller: 3.5
92 INFO: Python: 3.8.0
92 INFO: Platform: Windows-10-10.0.18362-SP0
94 INFO: wrote C:pythonSortsort.spec
97 INFO: UPX is not available.
99 INFO: Extending PYTHONPATH with paths
[‘C:\python\Sort’, ‘C:\python\Sort’]
99 INFO: checking Analysis
329 INFO: checking PYZ
329 INFO: Building PYZ because PYZ-00.toc is non existent
329 INFO: Building PYZ (ZlibArchive) C:pythonSortbuildsortPYZ-00.pyz
Traceback (most recent call last):
File «C:UserskikiAppDataLocalProgramsPythonPytho n38-32librunpy.py», line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File «C:UserskikiAppDataLocalProgramsPythonPytho n38-32librunpy.py», line 85, in _run_code
exec(code, run_globals)
File «C:pythonvenvScriptspyinstaller.exe__main__.p y», line 9, in <module>
File «c:pythonvenvlibsite-packagesPyInstaller__main__.py», line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File «c:pythonvenvlibsite-packagesPyInstaller__main__.py», line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File «c:pythonvenvlibsite-packagesPyInstallerbuildingbuild_main.py», line 844, in main
build(specfile, kw.get(‘distpath’), kw.get(‘workpath’), kw.get(‘clean_build’))
File «c:pythonvenvlibsite-packagesPyInstallerbuildingbuild_main.py», line 791, in build
exec(code, spec_namespace)
File «C:pythonSortsort.spec», line 18, in <module>
pyz = PYZ(a.pure, a.zipped_data,
File «c:pythonvenvlibsite-packagesPyInstallerbuildingapi.py», line 98, in __init__
self.__postinit__()
File «c:pythonvenvlibsite-packagesPyInstallerbuildingdatastruct.py», line 158, in __postinit__
self.assemble()
File «c:pythonvenvlibsite-packagesPyInstallerbuildingapi.py», line 128, in assemble
self.code_dict = {
File «c:pythonvenvlibsite-packagesPyInstallerbuildingapi.py», line 129, in <dictcomp>
key: strip_paths_in_code(code)
File «c:pythonvenvlibsite-packagesPyInstallerbuildingutils.py», line 652, in strip_paths_in_code
consts = tuple(
File «c:pythonvenvlibsite-packagesPyInstallerbuildingutils.py», line 653, in <genexpr>
strip_paths_in_code(const_co, new_filename)
File «c:pythonvenvlibsite-packagesPyInstallerbuildingutils.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)

Добавлено через 1 час 9 минут
pip install https://github.com/pyinstaller… lop.tar.gz

Прямая установка последней версии может быть совместима с Python 3.8

…Скомпилировало без ошибок. Создался файл exe, но при запуске выдает ошибку — Fatal error detected. failed to execute script sort

Добавлено через 10 минут
ВСЕ получилось!

1. Нужно было скачать по прямой ссылке (см выше)
2. Переместить файл из dist к своим файлам (у меня ico)

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



  1. How the TypeError Occurs in Python
  2. How to Resolve the TypeError: an integer is required

Solve the TypeError: An Integer Is Required in Python

Another most common error that occurs during code in Python is TypeError. It is an exception in Python.

You will get this error when you use an inappropriate data type of object in an operation.

This article will show how we get a TypeError in Python. Also, we will discuss the topic by using necessary examples and explanations to make the topic easier.

How the TypeError Occurs in Python

As we already discussed above, the cause of this error is the use of inappropriate data types in an operation. Suppose you have written the below Python program.

num=list(str(345678))
for i in num:
    print(chr(i))

When you try to run the above example, you will get an error like the one below.

Traceback (most recent call last):
  File "<string>", line 5, in <module>
TypeError: an integer is required (got type str)

The problem in the example above is that we passed an incompatible data type inside the function chr() on the line print(chr(i)).

Let’s see another example that produces the same error.

In this example, we will perform a divide operation on two variables. The Python code for this purpose is like below.

MyInt = 45
MyInt2 = "5"
Result = MyInt / MyInt2
print("Result is : ", Result)

In our example above, we divide the integer type variable by a string type variable incompatible with this operation. So after running this example, you will get an error like the one below.

Traceback (most recent call last):
  File "<string>", line 3, in <module>
TypeError: unsupported operand type(s) for /: 'int' and 'str'

How to Resolve the TypeError: an integer is required

To resolve this error, we need to fix the data type. For our first example, you can fix the code as follows:

num=list(str(345678))
for i in num:
    print(i)

Here you can notice that we just fixed the line where the data type is incompatible with the operation, and another part of the program remains the same.

After fixing the first example, you will get an output like the one below.

Now let’s solve our second example. To fix our second example, we need to remove the double quote from the second variable like below.

MyInt = 45
MyInt2 = 5
Result = MyInt / MyInt2
print("Result is : ", Result)

And you will see that the error was resolved, and you will get the output below.

Please take note that the commands and programs discussed here are written in the Python programming language.

Пишу: pyinstaller name.py на что получаю ошибку

File "d:новая папкаpython 3librunpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:новая папкаpython 3librunpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:Новая папкаPython 3Scriptspyinstaller.exe__main__.py", line 7, in <module>
  File "d:новая папкаpython 3libsite-packagesPyInstaller__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "d:новая папкаpython 3libsite-packagesPyInstaller__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingbuild_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingbuild_main.py", line 791, in build
    exec(code, spec_namespace)
  File "D:Новая папкаPython 3Scriptscalc.spec", line 18, in <module>
    pyz = PYZ(a.pure, a.zipped_data,
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingapi.py", line 98, in __init__
    self.__postinit__()
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingdatastruct.py", line 158, in __postinit__
    self.assemble()
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingapi.py", line 128, in assemble
    self.code_dict = {
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingapi.py", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingutils.py", line 652, in strip_paths_in_code
    consts = tuple(
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingutils.py", line 653, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "d:новая папкаpython 3libsite-packagesPyInstallerbuildingutils.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)

Как это исправить?

Понравилась статья? Поделить с друзьями:
  • Type error getclassinstances requires maxclass got undefined
  • Txdma error txdmastatus 4
  • Turkru tv мистер ошибка
  • Turkov коды ошибок
  • Turbobit error 9853