Closed SoothingMist closed 1 year ago
Try to run python -m aquacrop.scripts.initiate_library
in the terminal. If you have an error like RuntimeError: Attempted to compile AOT function without the compiler used by numpy.distutils present. Cannot find suitable msvc.
, install a msvc compiler. In my case, I have installed visual studio build tools, like in this video. https://www.youtube.com/watch?v=p_R3tXSq0KI
Followed what I had taken as a quick example from the ReadMe:
Install:
pip install aquacrop
Simple Code:
from aquacrop import AquaCropModel, Soil, Crop, InitialWaterContent from aquacrop.utils import prepare_weather, get_filepath
weather_file_path = get_filepath('tunis_climate.txt') model_os = AquaCropModel( sim_start_time=f"{1979}/10/01", sim_end_time=f"{1985}/05/30", weather_df=prepare_weather(weather_file_path), soil=Soil(soil_type='SandyLoam'), crop=Crop('Wheat', planting_date='10/01'), initial_water_content=InitialWaterContent(value=['FC']), ) model_os.run_model(till_termination=True) model_results = model_os.get_simulation_results().head() print(model_results)
Running "python -m aquacrop.scripts.initiate_library" yielded "No module named 'aquacrop'".
Not sure if this is an adequate solution but added these two lines at the top of the example given in the ReadMe:
import os os.environ['DEVELOPMENT'] = 'DEVELOPMENT'
The example then ran without crashing but generated numerous instances of:
soil.py:333: FutureWarning: In a future version, df.iloc[:, i] = newvals
will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either df[df.columns[i]] = newvals
or, if columns are non-unique, df.isetitem(i, newvals)
self.profile.loc[
Using Python v3.310.
The original error message is a bug that seems to only really occour on windows and should be fixed with the advice given be @farafehizoro. Its just an unfortunate feature of having the C compilation using numba which I would love to one day remove. It would just be a decent amount of work to refactor the aquacrop code to keep the same or similar speed.
Your solution using os.environ['DEVELOPMENT'] = 'DEVELOPMENT'
runs aquacrop in pure python (with the C compilation) so it works the same but will be slower.
I ran into the same problem as SoothingMist
i tried farafehizoro's solution, and indeed had to install Visual Studio Build Tools (got the 2022 version, but the msvc is from 2015) otherwise i was getting the mentioned error, i could not run "python -m aquacrop.scripts.initiate_library" in the terminal because i was getting an error like "distutils needs monkeypatch" (which seems related to this issue: https://github.com/pypa/setuptools/issues/2372 ), but i could run the initiate_library.py file from the ide (after importing setuptools, which somehow applies that monkeypatch). but then i still get the error "ModuleNotFoundError: No module named 'aquacrop.solution.solution_root_zone_water'"
the only thing that worked was using the development environment (os.environ['DEVELOPMENT'] = 'DEVELOPMENT')
These common solutions to installation problems will be added to the readme in the upcoming minor update so closing this issue.
No module named aquacrop.scripts.initiate_library Traceback (most recent call last): File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "D:\NewIrrigationExperiment\AquaCrop-Python\venv\lib\site-packages\aquacrop__init__.py", line 3, in
from .core import AquaCropModel
File "D:\NewIrrigationExperiment\AquaCrop-Python\venv\lib\site-packages\aquacrop\core.py", line 48, in
from .timestep.run_single_timestep import solution_single_time_step
File "D:\NewIrrigationExperiment\AquaCrop-Python\venv\lib\site-packages\aquacrop\timestep\run_single_timestep.py", line 12, in
from ..solution.irrigation import irrigation
File "D:\NewIrrigationExperiment\AquaCrop-Python\venv\lib\site-packages\aquacrop\solution\irrigation.py", line 7, in
from .solution_root_zone_water import root_zone_water
ModuleNotFoundError: No module named 'aquacrop.solution.solution_root_zone_water'