Amber-MD / pytraj

Python interface of cpptraj
https://amber-md.github.io/pytraj
170 stars 38 forks source link

Build pytraj error when installing Amber22 #1618

Open ursulap opened 1 year ago

ursulap commented 1 year ago

Hello, I am new to this and I have been scooting for solutions for a few days now. I am installing Amber 22. I am in the "make install" step. Here it got as far as 94%.

The error at step 94% is related to "Building pytraj"...

My PATH is:

/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/llvm/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/ATSAS/bin

I have both .zshrc and .zshr, in my home directory, and they both include the following:

export PATH="/opt/homebrew/opt/llvm/bin:$PATH" export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/libomp/include" export PATH="/opt/homebrew/opt/llvm/bin:$PATH"

A little detour: I found that if I didn't direct the clang compiler to "/opt/homebrew/opt/llvm/bin", it would use the one from Apple at: "/usr/bin/", and thus give an openmp error: "clang: error: unsupported option '-fopenmp'"

It appears to me that in the 94% step of "make install" for amber22 the code looks for the apple clang compiler instead of the one from brew (see below). How do I go about solving this issue? Is this in fact the issue (it does have a "--disable-openmp" ? Thank you!!

[ 94%] Building pytraj native library sys.argv ['setup.py', 'build', '--disable-openmp'] Original compiler envs CXX = /usr/bin/clang++ CC = /usr/bin/clang COMPILER = use_pip = False, cpptraj_home = compile_c_extension = True 2.0.6 use_prebuilt_cythonized_files = False pytraj is inside AMBERHOME using environment: CC=/usr/bin/clang, CXX=/usr/bin/clang++ using CC=/usr/bin/clang, CXX=/usr/bin/clang++ Final compiler envs CXX = /usr/bin/clang++ CC = /usr/bin/clang COMPILER = Traceback (most recent call last): File "/Applications/Amber/amber22_src/AmberTools/src/pytraj/setup.py", line 171, in prepare_env_for_osx() File "/Applications/Amber/amber22_src/AmberTools/src/pytraj/setup.py", line 165, in prepare_env_for_osx warnings.warn("darwin_major_to_osx_map needs to be updated! Report this issue if build fails.") NameError: name 'warnings' is not defined make[2]: [AmberTools/src/pytraj/CMakeFiles/python-build/pytraj-build.stamp] Error 1 make[1]: [AmberTools/src/pytraj/CMakeFiles/pytraj.dir/all] Error 2 make: *** [all] Error 2

hainm commented 1 year ago

hi @ursulap Please edit the /Applications/Amber/amber22_src/AmberTools/src/pytraj/setup.py to add import warnings at the top. Sorry.

dacase commented 1 year ago

On Sat, Dec 10, 2022, ursulap wrote:

I am trying to install the MD program Amber22. I am at the 3rd step of the process,"make install" (the first is just "tar" two files, the second is "./run_cmake"). I get to 94% install and then it is derailed. The details of 94% and onwards are below....

Thanks for all the details (really!) but apoligies if I am getting things confused.

git clone https://github.com/Amber-MD/cpptraj cd cpptraj bash configure -shared -openmp gnu

Did you try leaving out the -openmp flag? There are a very places where cpptraj could benefit, but most users will never enounter them. That should keep the -fopenmp flag out of the picture. (Caveat: I've never installed pytraj from Github.

[ 94%] Building pytraj native library File "/Applications/Amber/amber22_src/AmberTools/src/pytraj/setup.py", line 165, in prepare_env_for_osx warnings.warn("darwin_major_to_osx_map needs to be updated! Report this issue if build fails.")

Ah...what is your OSX version? It's really bad (tm) that the pytraj setup needs to know intimate details of what OSX version you have, and that this needs to get updated every time Apple does something. Do you by any chance have OSX 13 (Ventura)?

...thanks...dac

ursulap commented 1 year ago

Hi, Thank you for responding! First, I want to thank Hai since indeed adding - literally - "import warnings" at the top of the setup.py file (with no quotes in the script) in /Applications/Amber/amber22_src/AmberTools/src/pytraj/setup.py solved the issue. Right now I am running the tests. Thank you!

David, also thank you for responding and going through my crazy detour! To answer your questions (in reverse order):

Second, yes the OS is Ventura => 13

And first, yes I did try to run without the -fopenmp. The python script however had " #include " which then resulted in an error that such a file could not be found. If I removed this line from the script, then errors arouse too because several variables had "omp" . For example: "tid = omp_get_thread_num();"

Hopefully I am above water now and (almost) ready to run amber22....we'll see :-) If I run into a problem again I will reach out :-)

Thank you so much!! best, ursula