Мой скрипт Python отлично работает при выполнении. Однако у меня есть запросы на него как на отдельный файл .exe. Итак, я пытаюсь использовать Pyinstaller для его преобразования. Я преодолел/исправил много ошибок, но эта ускользает от меня!
Traceback (most recent call last):
File "Convert_TopStepX_Orders_to_Pinscript.py", line 132, in
modify_spreadsheet(os.path.join(script_dir, xlsx_file_), output_file)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 139, in join
File "", line 188, in _check_arg_types
TypeError: join() argument must be str, bytes, or os.PathLike object, not 'list'
[PYI-21372:ERROR] Failed to execute script 'Convert_TopStepX_Orders_to_Pinscript.py' due to unhandled exception!
Будем благодарны за любую помощь!
Код со строкой 139:
# Get the current date
current_date = datetime.now().strftime("%Y-%m-%d")
# Get a list of all files in the folder that end with ".xlsx"
split_files = [f for f in os.listdir(output_folder) if f.endswith(".xlsx")]
# Loop over the split files
for split_file in split_files:
# Load the Excel spreadsheet
df = pd.read_excel(f"{output_folder}/{split_file}")
# Determine the number of rows in the spreadsheet
num_rows = len(df)
# Determine the number of splits needed
num_splits = (num_rows + 20) // 25
# Loop over the splits
for i in range(num_splits):
# Determine the start and end row indices for this split
start_row = i * 25
end_row = min((i + 1) * 25 + 5, num_rows)
# Extract the subset of rows for this split
subset_df = df.iloc[start_row:end_row]
# Save the subset to a new spreadsheet with "modified" at the end of the file name
output_file = f"{output_folder}/{split_file[:-5]}_split_{str(i+1)}.xlsx"
subset_df.to_excel(output_file, index=False)
print(f"Split {split_file} and saved to {output_file}")
# Delete unwanted files
for file in os.listdir(output_folder):
file_path = f"{output_folder}/{file}"
if not file.endswith(".txt") and not "split" in file and os.path.exists(file_path):
try:
os.remove(file_path)
except Exception as e:
print(f"Error deleting file {file}: {str(e)}")
Код со строкой 188:
# Get a list of all files in the folder that start with "split"
split_files = [f for f in os.listdir(output_folder) if f.endswith(".xlsx")]
# Loop over the split files
for file in split_files:
try:
# Load the Excel spreadsheet
data = pd.read_excel(f"{output_folder}/{file}", header=None)
# Count the number of rows
row_count = data.shape[0]
# Write the result to a new notepad
base_name = os.path.splitext(file)[0]
output_file = f"{output_folder}/{re.sub(r'modified_split|modified', 'trades', base_name)}.txt"
with open(output_file, 'w', encoding='utf-8') as f:
# Add the color definitions to the top of the file
f.write(f"\\@version=5\n")
f.write(f"indicator('My Executions', overlay=true)\n") # Modified line
f.write("i_buy_col = input.color(color.rgb(109, 223, 2, 0), 'Color for Buy Arrows')\n")
f.write("i_close_col = input.color(color.rgb(255, 255, 255, 0), 'Color for Close Order Arrows')\n")
f.write("i_sell_col = input.color(color.rgb(251, 255, 0, 0), 'Color for Sell Arrows')\n")
f.write("i_stop_loss_col = input.color(color.rgb(186, 0, 211, 0), 'Color for Stop Loss Arrows')\n")
f.write("i_take_profit_col = input.color(color.rgb(0, 110, 255, 0), 'Color for Take Profit Arrows')\n\n")
for i in range(row_count):
f.write(f"data{i} = float(na)\n")
for i in range(len(data)):
f.write(f"data{i} := timestamp({data.iloc[i, 1]}) >= time and timestamp({data.iloc[i, 1]}) < time_close ? {data.iloc[i, 2]} : data{i}\n")
# Iterate over the rows in the spreadsheet
for i in range(len(data)):
# Write the text to the notepad
f.write(f"plotchar(data{i}, {data.iloc[i, 3]}, {data.iloc[i, 4]}, force_overlay = true, location=location.absolute, size=size.tiny)\n")
print(f"Created Text Files: {file}, added pine script and saved to {output_file}")
except Exception as e:
print(f"Error processing file {file}: {str(e)}")
Подробнее здесь: https://stackoverflow.com/questions/791 ... bytes-or-o
Преобразование Python / Pyinstaller: TypeError: аргумент join() должен быть объектом str,bytes или os.PathLike, а не «сп ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение