Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: gcc or gfortran may be required before the installation #80

Closed
JouleCai opened this issue Aug 10, 2021 · 16 comments · Fixed by #90
Closed

BUG: gcc or gfortran may be required before the installation #80

JouleCai opened this issue Aug 10, 2021 · 16 comments · Fixed by #90
Labels
bug documentation Documentation changes
Milestone

Comments

@JouleCai
Copy link

Describe the bug
I cannot install the package until I install the gcc or gfortran compilers. Test env: anaconda virtual env. Python: 3.8.

@JouleCai JouleCai added the bug label Aug 10, 2021
@aburrell
Copy link
Owner

aburrell commented Aug 10, 2021

Yes, this is true. Because the core code is Fortran, you need a fortran compiler installed. I checked the docs and you're right that this isn't listed in the instructions where it should be.

@aburrell aburrell added the documentation Documentation changes label Aug 10, 2021
@aburrell aburrell added this to the 1.1.1 Release milestone Aug 10, 2021
@ljlamarche
Copy link
Collaborator

Here are the steps that worked for me to install apexpy using a conda environment and MacOS High Sierra. It wasn't entirely straight forward, so I wanted to record it in case it helps someone else.

  1. Check that the MacOS SDKs are installed. These should be in /Library/Developer/CommandLineTools/SDKs/. If this folder is empty or does not exist, you may need to install the Mac command line developer tools.
  2. Create a conda-build variant config file and save it somewhere. I put mine in the top folder of my conda distribution just to keep track of it easily (/opt/miniconda3/conda_build_config.ymal). This should point to the location of the sdk, so at minimum, it should contain the following:
CONDA_BUILD_SYSROOT:
  - /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
  1. Modify your .condarc file to point to your conda-build config file. This should be in your home directory (~/.condarc). Add the following sections, but use your path to conda_build_config.ymal from the previous step.
conda_build:
  config_file: /opt/miniconda3/conda_build_config.yaml
  1. Create fresh conda environment (not strictly nessessary if you have an existing environment, but helpful for testing)
$ conda create --name apexpy_test python=3.9
$ conda activate apexpy_test
  1. Install the Anaconda compiler tools
$ conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64
  1. Install apexpy with the no binary option:
$ pip install --no-binary :apexpy: apexpy

If you've recently tried and failed to install apexpy in this environment, you may also need the no cache option:

$ pip install --no-cache --no-binary :apexpy: apexpy

This is NOT an apexpy specific issue - it's just somewhat convoluted to get functioning compilers installed in a conda environment on MacOS now. I actually had a bunch of fortran-wrapped-python packages that weren't working until I got this figured out. Also, small disclaimer, this really isn't my area of expertise and there may be a better way to do this, but I wanted to share in case anyone else was having issues with the same configuration.

@hlmxlj2018
Copy link

windows 10 ,Unable to import fortranepex module

@hlmxlj2018
Copy link

Here are the steps that worked for me to install apexpy using a conda environment and MacOS High Sierra. It wasn't entirely straight forward, so I wanted to record it in case it helps someone else.

  1. Check that the MacOS SDKs are installed. These should be in /Library/Developer/CommandLineTools/SDKs/. If this folder is empty or does not exist, you may need to install the Mac command line developer tools.
  2. Create a conda-build variant config file and save it somewhere. I put mine in the top folder of my conda distribution just to keep track of it easily (/opt/miniconda3/conda_build_config.ymal). This should point to the location of the sdk, so at minimum, it should contain the following:
CONDA_BUILD_SYSROOT:
  - /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
  1. Modify your .condarc file to point to your conda-build config file. This should be in your home directory (~/.condarc). Add the following sections, but use your path to conda_build_config.ymal from the previous step.
conda_build:
  config_file: /opt/miniconda3/conda_build_config.yaml
  1. Create fresh conda environment (not strictly nessessary if you have an existing environment, but helpful for testing)
$ conda create --name apexpy_test python=3.9
$ conda activate apexpy_test
  1. Install the Anaconda compiler tools
$ conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64
  1. Install apexpy with the no binary option:
$ pip install --no-binary :apexpy: apexpy

If you've recently tried and failed to install apexpy in this environment, you may also need the no cache option:

$ pip install --no-cache --no-binary :apexpy: apexpy

This is NOT an apexpy specific issue - it's just somewhat convoluted to get functioning compilers installed in a conda environment on MacOS now. I actually had a bunch of fortran-wrapped-python packages that weren't working until I got this figured out. Also, small disclaimer, this really isn't my area of expertise and there may be a better way to do this, but I wanted to share in case anyone else was having issues with the same configuration.

Can you help me?

@ljlamarche
Copy link
Collaborator

I'm not sure about Windows 10, sorry. Perhaps #65 is helpful?

@aburrell
Copy link
Owner

aburrell commented Nov 2, 2021

I also recently had trouble on Windows 10, and wasn't able to solve the issue. Generally, if fortranapex isn't building it's because there's a mismatch between the python set up and the fortran compiler. If you can supply your full set-up details (which python you're using, which fortran compiler you're using, verifying that both are on your path, anything else that may be important), that might be helpful.

The solution we ended up going with was a linux dual-boot, but that's not ideal.

@asreimer
Copy link
Collaborator

asreimer commented Nov 2, 2021

More specifically, this comment: #65 (comment)

Following that does work on windows 10. I'm typing this comment from my windows 10 desktop with apexpy installed and working on it.

@hlmxlj2018
Copy link

hlmxlj2018 commented Nov 2, 2021 via email

@asreimer
Copy link
Collaborator

asreimer commented Nov 2, 2021

@hlmxlj2018, Did you install mingw as it says here: https://wiki.python.org/moin/WindowsCompilers#GCC_-_MinGW-w64_.28x86.2C_x64.29?

Don't forget to add it to the PATH variable: "Add C:\MinGW_w64\bin to the PATH environment variable." Or whereever the mingw/bin directory is on your computer.

@hlmxlj2018
Copy link

hlmxlj2018 commented Nov 2, 2021 via email

@asreimer
Copy link
Collaborator

asreimer commented Nov 2, 2021

What version of anaconda? conda --version

@hlmxlj2018
Copy link

hlmxlj2018 commented Nov 2, 2021 via email

@hlmxlj2018
Copy link

hlmxlj2018 commented Nov 2, 2021 via email

@ljlamarche
Copy link
Collaborator

Hm, yeah, that definitely sounds like the kind of issue that comes up when python and your fortran compilers aren't integrated nicely. I don't think I'll be very helpful with this one, sorry, but this thread might give you a few ideas.
https://stackoverflow.com/questions/48826283/compile-fortran-module-with-f2py-and-python-3-6-on-windows-10

@aburrell
Copy link
Owner

aburrell commented Apr 13, 2022

I just tried this when migrating our CI to GitHub Actions from Appveyor. To get the necessary environment in Windows for Numpy to work correctly, I also needed to install scipy. Here's where I was able to figure out why: https://stackoverflow.com/questions/28190534/windows-scipy-install-no-lapack-blas-resources-found

This command assumes you're compiling the source instead of getting it from pip, but if you replace the setup.py command with the pip command it should work.

conda install -q -c msys2 m2w64-toolchain scipy numpy
python setup.py config --compiler=mingw32 --fcompiler=gfortran install

@aburrell aburrell linked a pull request Oct 31, 2022 that will close this issue
11 tasks
@aburrell
Copy link
Owner

Added many of these comments to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation Documentation changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants