pypsa-meets-earth / pypsa-earth

PyPSA-Earth: A flexible Python-based open optimisation model to study energy system futures around the world.
https://pypsa-earth.readthedocs.io/en/latest/
207 stars 167 forks source link

unable to install Ipopt on Mac #968

Open nikhil550 opened 4 months ago

nikhil550 commented 4 months ago

Checklist

Describe the Bug

Installing pypsa earth on Mac M1, mamba was unable to install Ipopt dependecy.

Error Message

mamba env create -f envs/environment.yaml yielded the following error:

Could not solve for environment specs
The following package could not be installed
└─ ipopt <3.13.3  does not exist (perhaps a typo or a missing channel).

with conda env update:

PackagesNotFoundError: The following packages are not available from current channels:

  - ipopt[version='<3.13.3']
davide-f commented 4 months ago

Hello @nikhil550 ! Thanks for notifying. That is weird as generally CI passes, it may be really OS-specific. You may try to drop the dependency in the env/environment file, just to create the environment. Then you may install ipopt in mac using an alternative approach. That should work.

It is worth keeping this issue open so that we track the problem and later revise the environment as the #494 issue is solved, which enables to upgrade pypsa and support the solving capabilities using linopy.

GbotemiB commented 4 months ago

I faced the same issue. Removing the constraint on ipopt in the environment.yml file should solve the issue.

nikhil550 commented 4 months ago

I was able to install by removing removing Ipopt and installing locally per the recommendation above.

mfripp commented 2 months ago

This occurs because envs/environment.yaml requires ipopt <3.13.3 but the first version available for Apple silicon (arm/M1 or later) is 3.14.5. You can see this by running the following commands:

# search for macOS arm architecture
CONDA_SUBDIR=osx-arm64 conda search ipopt

# search for macOS x86 architecture
CONDA_SUBDIR=osx-64 conda search ipopt

It is possible to work around this by running CONDA_SUBDIR=osx-64 mamba env create -f envs/environment.yaml, which will create an x86 environment. But pypsa-earth will then in emulation mode, which reduces performance. Or users can change the ipopt version dependency in envs/environment.yaml, with unknown side effects.

Would it be possible to update pypsa-earth to work with ipopt 3.14.5 or later?

ekatef commented 2 months ago

Thanks for sharing your experience @mfripp!

As discussed above, that is a system-dependent issue a clean solution for which requires introducing consecutive fixes into the environment. For the newer Mac OS versions, removing the version constraint for ipopt is known to work fine (although, for other OS the constraint may be still needed).

finozzifa commented 1 day ago

Hi all,

Current situation In the environment.yaml file we enforce ipopt<3.13.3. This works fine for CI-windows and CI-linux. However it does not work for CI-mac, because there are no available versions of ipopt<3.13.3 on Mac.

Experiment

I tried to remove ipopt<3.13.3. In this case, CI-linux and CI-Mac work fine, however CI-windows fails with the following error WARNING:__main__:The configured solverglpkdoes not support quadratic objectives. Falling back toipopt. WARNING:pyomo.solvers:Could not locate the 'ipopt' executable, which is required for solver ipopt ERROR:_helpers:An error happened in module 'C:\\Users\\runneradmin\\miniconda3\\envs\\pypsa-earth\\lib\\site-packages\\pyomo\\opt\\solver\\shellcmd.py', function 'available': No executable found for solver 'ipopt'.

After a bit of reading I found an explanation at this link.