TypeError: cannot pickle 'TextIOWrapper' instances пайтон
ЧТо делать? Делаю запуск майнкрафта на python
Installation completerTraceback (most recent call last):
File "C:\Users\lukic\OneDrive\Desktop\PyCraft\pycraft_noask.py", line 38, in <module>
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(version=version, minecraft_directory=minecraft_directory, options=options))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lukic\AppData\Local\Programs\Python\Python312\Lib\site-packages\minecraft_launcher_lib\command.py", line 173, in get_minecraft_command
options = copy.deepcopy(options)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lukic\AppData\Local\Programs\Python\Python312\Lib\copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "C:\Users\lukic\AppData\Local\Programs\Python\Python312\Lib\copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\lukic\AppData\Local\Programs\Python\Python312\Lib\copy.py", line 151, in deepcopy
rv = reductor(4)
^^^^^^^^^^^
TypeError: cannot pickle 'TextIOWrapper' instances
import minecraft_launcher_lib
import subprocess
minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory().replace('minecraft', 'PyCraft')
print('PyCraft, made by: EgorLukichev')
def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█', printEnd="\r"):
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
filledLength = int(length * iteration // total)
bar = fill * filledLength + '-' * (length - filledLength)
print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end=printEnd)
if iteration == total:
print()
def maximum(max_value, value):
max_value[0] = value
version = '1.12.2'
username = open('nickname.txt','r')
print('=======================================================================================')
max_value = [0]
callback = {
"setStatus": lambda text: print(text, end='r'),
"setProgress": lambda value: printProgressBar(value, max_value[0]),
"setMax": lambda value: maximum(max_value, value)
}
minecraft_launcher_lib.install.install_minecraft_version(versionid=version, minecraft_directory=minecraft_directory, callback=callback)
options = {
'username': username,
}
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(version=version, minecraft_directory=minecraft_directory, options=options))
import minecraft_launcher_lib
import subprocess
minecraft_directory = minecraft_launcher_lib.utils.get_minecraft_directory().replace('minecraft', 'PyCraft')
print('PyCraft, made by: EgorLukichev')
def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█', printEnd="\r"):
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
filledLength = int(length * iteration // total)
bar = fill * filledLength + '-' * (length - filledLength)
print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end=printEnd)
if iteration == total:
print()
def maximum(max_value, value):
max_value[0] = value
version = '1.12.2'
# Считайте имя пользователя из файла как строку
with open('nickname.txt', 'r') as file:
username = file.read().strip()
print('=======================================================================================')
max_value = [0]
callback = {
"setStatus": lambda text: print(text, end='r'),
"setProgress": lambda value: printProgressBar(value, max_value[0]),
"setMax": lambda value: maximum(max_value, value)
}
minecraft_launcher_lib.install.install_minecraft_version(versionid=version, minecraft_directory=minecraft_directory, callback=callback)
options = {
'username': username, # Передайте строку вместо файла
}
subprocess.call(minecraft_launcher_lib.command.get_minecraft_command(version=version, minecraft_directory=minecraft_directory, options=options))