Closed JouleCai closed 1 year ago
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.
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.
/Library/Developer/CommandLineTools/SDKs/
. If this folder is empty or does not exist, you may need to install the Mac command line developer tools./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
.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
$ conda create --name apexpy_test python=3.9
$ conda activate apexpy_test
$ conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64
$ 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.
windows 10 ,Unable to import fortranepex module
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.
- 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.- 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
- 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 toconda_build_config.ymal
from the previous step.conda_build: config_file: /opt/miniconda3/conda_build_config.yaml
- 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
- Install the Anaconda compiler tools
$ conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64
- 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?
I'm not sure about Windows 10, sorry. Perhaps #65 is helpful?
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.
More specifically, this comment: https://github.com/aburrell/apexpy/issues/65#issuecomment-789335617
Following that does work on windows 10. I'm typing this comment from my windows 10 desktop with apexpy installed and working on it.
Windows 10, anacond, python 3.6. I have installed gfortran on my computer. I have done so. Create a distutils.cfg file. But there are still problems. Fortranepex module cannot import
------------------ 原始邮件 ------------------ 发件人: "aburrell/apexpy" @.>; 发送时间: 2021年11月2日(星期二) 晚上11:55 @.>; @.**@.>; 主题: Re: [aburrell/apexpy] BUG: gcc or gfortran may be required before the installation (#80)
More specifically, this comment in 65: #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.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
@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.
I have do it
------------------ 原始邮件 ------------------ 发件人: "aburrell/apexpy" @.>; 发送时间: 2021年11月3日(星期三) 凌晨0:06 @.>; @.**@.>; 主题: Re: [aburrell/apexpy] BUG: gcc or gfortran may be required before the installation (#80)
@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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
What version of anaconda? conda --version
anaconda3
------------------ 原始邮件 ------------------ 发件人: "aburrell/apexpy" @.>; 发送时间: 2021年11月3日(星期三) 凌晨0:08 @.>; @.**@.>; 主题: Re: [aburrell/apexpy] BUG: gcc or gfortran may be required before the installation (#80)
What version of anaconda? conda --version
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
from . import fortranapex as fa ImportError: DLL load failed:
------------------ 原始邮件 ------------------ from . import fortranapex as fa ImportError: DLL load failed: 发件人: "aburrell/apexpy" @.>; 发送时间: 2021年11月3日(星期三) 凌晨0:08 @.>; @.**@.>; 主题: Re: [aburrell/apexpy] BUG: gcc or gfortran may be required before the installation (#80)
What version of anaconda? conda --version
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
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
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
Added many of these comments to the documentation.
Describe the bug I cannot install the package until I install the gcc or gfortran compilers. Test env: anaconda virtual env. Python: 3.8.