Alternatives to convert a script to Python 3.x: How can I fix Python 2.7 compatibility issues in this case?

35 Views Asked by At

I am running a script written by someone else as a replication. The original script and all the files were created with Python 2.7. I have three scripts: 'prediction_2021', 'performance_2020' and my current script 'prediction' which runs xgboost. I was running everything on a Python 2.7 virtual environment but the XGBoost package stopped working, so I tried to update everything to run it in Python 3.11 in MacOS. 'prediction_2021' and 'performance_2020' both load pickle and other types files of files and the file won't load in Python 3.11, I tried saving it in different formats (CSV, YAML, JSON) but when I tried to load it, I get different errors. This is the usage of the first two scripts in my third script:

from prediction_2021 import get_pred, preprocess_data
from performance_2020 import get_bootstrap, chunks, aggregated_performance_table

I have two questions:

  1. Is there anyway I can use XGBoost package in Python 2.7 now that the support is dropped?
  2. Is my only option to just try to rewrite the first two scripts to read the files in some format in Python 3.11?

I tried saving the files in different formats and just correcting the reading parts in the original two scripts. I also tried to restart and reload the packages in my virtual environment. Thanks.

0

There are 0 best solutions below