I'm trying to build an auto-installer for a modpack I've made for a Minecraft server in Python. It installs Forge by copying the files from the forgefiles
folder (unzipped from files.zip
) to %appdata%\.minecraft\versions
, and the mods from the mods
folder (again, unzipped from files.zip
) to %appdata%\.minecraft\mods
. However, when I run my code, it comes up with this:
AutoInstaller Alpha 1
Created by ByeMC
This installer will save to "%appdata%\.minecraft". Press enter to continue.
Copying mods
Traceback (most recent call last):
File "Z:\Mods\Minecraft\Modpacks\MiinCraft SMP\autoinstaller_v1.py", line 17, in <module>
shutil.copy(filepath, "%appdata%\.minecraft")
File "C:\Users\qwerty\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 418, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\qwerty\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'Z:\\Mods\\Minecraft\\Modpacks\\MiinCraft SMP\\mods'
Here is my code:
print('AutoInstaller Alpha 1')
print('Created by ByeMC')
input('This installer will save to "%appdata%\.minecraft". Press enter to continue. ')
import shutil
import os
from zipfile import ZipFile
with ZipFile('files.zip', 'r') as zip:
zip.extractall()
print('Copying mods')
dirname = os.path.dirname(__file__)
filepath = os.path.join(dirname, "mods")
shutil.copy(filepath, "%appdata%\.minecraft")
print('Copied mods to "%appdata%\.minecraft\mods". Copying Forge Files.')
filepath = os.path.join(dirname, "\forgefiles")
shutil.copy(filepath, "%appdata%\.minecraft\versions")
print('Copied Forge Files.')
I would appreciate any help you can give.
[Edit: I know the code above only works in Windows, all my friends palying on the server use Windows]