daquinterop / Py_DSSATTools

A Python library for crop modeling using DSSAT
GNU General Public License v3.0
45 stars 16 forks source link

[Errno 8] Exec format error running the code #5

Closed guegueniat closed 11 months ago

guegueniat commented 1 year ago

Hello, I have just tried to run the code as described in the first example:

from DSSATTools import *
from datetime import datetime, timedelta

import numpy as np
import pandas as pd

DATES = pd.date_range('2000-01-01', '2010-12-31')
N = len(DATES)

df_weather = pd.DataFrame(columns = ['TMIN', 'TMAX', 'RAIN', 'SRAD', 'RHUM'],
                          index = DATES)

df_weather['TMIN'] = np.random.gamma(10, 1, N)
df_weather['TMAX'] = df_weather['TMIN'] + np.random.gamma(5., .5, N)
df_weather['RAIN'] = [0.0]* N
df_weather['SRAD'] = np.random.gamma(10, 1.5, N)
df_weather['RHUM'] = 100 * np.random.beta(1.5, 1.15, N)

WTH_DATA = WeatherData(df_weather)

coords = {'ELEV': 33,
          'LAT': 0,
          'LON': 0,
          'INSI': 'name'}

wth = WeatherStation(WTH_DATA, coords)

soil = SoilProfile(default_class='SIL')

crop = Crop('Maize')

man = Management(cultivar = 'IB0001',
                 planting_date = DATES[10])

man.simulation_controls['HARVS'] = 'A' # Automatic
man.simulation_controls['IRRIG'] = 'F' # Fixed amount automatic
man.simulation_controls['FERTI'] = 'D' # Days after planting

dssat = DSSAT()
dssat.setup()
dssat.run(soil = soil, weather = wth, crop = crop, management = man)

Then, I have got the following error:

OSError: [Errno 8] Exec format error: '/var/folders/fc/q617vtwn0n1dj5xdkq2l5ng80000gn/T/dssatrdpojkco/static/bin/dscsm048' It appears when self._execute_child is called from subprocess.py in Python 3.9 whilst run.py in DSSATTools is run .

Thank you for your help :)

daquinterop commented 1 year ago

Hi, what OS and Python's version are you using?

guegueniat commented 1 year ago

Hello,

Thank you for your quick reply.

I'm using OS Monterey 12.6.3 and Python 3.9.

daquinterop commented 1 year ago

Unfortunately I haven't tested the library for macOS. The error you are presenting is probably due to the DSSAT executable that the library is using, so far I've included an exe for Windows and other for Linux, but not one for macOS since I was hoping that the same exe of Linux would work on macOS. I can only recommend you to use the library on a Linux environment. I'll try to compile DSSAT on macOS for latter releases.

guegueniat commented 1 year ago

Hello, I have just tried with Linux through Ubuntu (22.04), on a virtual machine and I have got the same error. Would downgrading a good solution?

guegueniat commented 1 year ago

Updates:

quanghuy205 commented 11 months ago

I've got same error on MacOS, M1 chip. I hope there will be an update for MacOS in the next releases! Thanks!