Ich verwende einen Mac und ich möchte eine .App -Anwendung für die Dateiextraktion mit Python erstellen. '/Users/faresmohamedmomen/build/bdist.macosx-10.13-universal2/python3.13-standalone/app/collect/packaging-24.2.dist-info'
Setup.py:
from setuptools import setup
APP = ['main.py'] # Replace 'main.py' with the actual name of your Python script
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'packages': [], # Add any libraries you need, e.g. 'numpy', 'requests', etc.
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
< /code>
Main.py:
import zipfile
import rarfile
import os
import sys
# Function to unzip a file
def unzip_file(zip_path, extract_to):
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_to)
print(f"Files extracted to {extract_to}")
# Function to unrar a file
def unrar_file(rar_path, extract_to):
with rarfile.RarFile(rar_path) as rar_ref:
rar_ref.extractall(extract_to)
print(f"Files extracted to {extract_to}")
# Main app function
def main():
if len(sys.argv) < 2:
print("No file provided!")
return
file_path = sys.argv[1] # Get the file path from command-line argument
extract_to = input("Enter the directory to extract to: ")
# Make sure the extraction directory exists
if not os.path.exists(extract_to):
os.makedirs(extract_to)
# Check the file type and extract accordingly
if zipfile.is_zipfile(file_path):
unzip_file(file_path, extract_to)
elif rarfile.is_rarfile(file_path):
unrar_file(file_path, extract_to)
else:
print("Invalid file type. Only .zip and .rar are supported.")
if __name__ == "__main__":
main()
Ich verwende einen Mac und [url=viewtopic.php?t=14917]ich möchte[/url] eine .App -Anwendung für die Dateiextraktion mit Python erstellen. '/Users/faresmohamedmomen/build/bdist.macosx-10.13-universal2/python3.13-standalone/app/collect/packaging-24.2.dist-info' Setup.py: [code]from setuptools import setup
APP = ['main.py'] # Replace 'main.py' with the actual name of your Python script DATA_FILES = [] OPTIONS = { 'argv_emulation': True, 'packages': [], # Add any libraries you need, e.g. 'numpy', 'requests', etc. }
# Function to unzip a file def unzip_file(zip_path, extract_to): with zipfile.ZipFile(zip_path, 'r') as zip_ref: zip_ref.extractall(extract_to) print(f"Files extracted to {extract_to}")
# Function to unrar a file def unrar_file(rar_path, extract_to): with rarfile.RarFile(rar_path) as rar_ref: rar_ref.extractall(extract_to) print(f"Files extracted to {extract_to}")
# Main app function def main(): if len(sys.argv) < 2: print("No file provided!") return
file_path = sys.argv[1] # Get the file path from command-line argument extract_to = input("Enter the directory to extract to: ")
# Make sure the extraction directory exists if not os.path.exists(extract_to): os.makedirs(extract_to)
# Check the file type and extract accordingly if zipfile.is_zipfile(file_path): unzip_file(file_path, extract_to) elif rarfile.is_rarfile(file_path): unrar_file(file_path, extract_to) else: print("Invalid file type. Only .zip and .rar are supported.")
Ich habe ein Problem, in dem meine Mac-Katalysatoranwendung an Tester verteilt wird, während sie normal auf meinem Computer ausgeführt wird. Er stürzt sofort nach dem Start auf andere ab, ohne dass...
Ich erhalte immer wieder die gleiche Fehlermeldung von einem geplanten BashOperator, der gerade eine Auffüllung durchführt (es liegt über einen Monat „im Rückstand“).