firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
498 stars 157 forks source link

Installation failure with PETSC #1769

Closed elma16 closed 4 years ago

elma16 commented 4 years ago

Hi, I'm trying to install Firedrake on my Mac (version 10.15.5) and my installation fails when I try to build PETSC. Attached is the firedrake-install file. I'm aware there are similar issues reported here, and I tried to replicate fixes (such as removing anaconda3, using brew doctor and trying --minimal-petsc) but it still does not work. Any help would be greatly appreciated.

firedrake-install.log

wence- commented 4 years ago

Hmm, the last thing that that log provides is:

2020-07-02 22:13:53,454 INFO   Installing petsc/
2020-07-02 22:13:53,718 INFO   Downloading Eigen from 'https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz' to 'eigen-3.3.3.tgz'
2020-07-02 22:13:53,887 INFO   

With the python you used to run firedrake-install, can you run:

import hashlib
import urllib.request
tarball = "eigen-3.3.3.tgz"
url = "https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz"
sha = hashlib.sha256()
expect = ("df6082711532336354466bab70f66c16ff88e616ac3884eba555b6f0b4860e65",
          "94878cbfa27b0d0fbc64c00d4aafa137f678d5315ae62ba4aecddbd4269ae75f")
urllib.request.urlretrieve(url, filename=tarball)
with open(tarball, "rb") as f:
    while True:
        data = f.read(65536)
        if not data:
            break
        sha.update(data)
actual = sha.hexdigest()
print(actual)
print(actual in expect)
elma16 commented 4 years ago

@wence- thank you for the swift reply. Here is what I get when I input this.


The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ElliottsMacBook:~ elliottmacneil$ python3 
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import urllib.request
>>> tarball = "eigen-3.3.3.tgz"
>>> url = "https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz"
>>> sha = hashlib.sha256()
>>> expect = ("df6082711532336354466bab70f66c16ff88e616ac3884eba555b6f0b4860e65",
...           "94878cbfa27b0d0fbc64c00d4aafa137f678d5315ae62ba4aecddbd4269ae75f")
>>> urllib.request.urlretrieve(url, filename=tarball)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>
>>> with open(tarball, "rb") as f:
...     while True:
...         data = f.read(65536)
...         if not data:
...             break
...         sha.update(data)
... actual = sha.hexdigest()
  File "<stdin>", line 7
    actual = sha.hexdigest()
         ^
SyntaxError: invalid syntax
>>> print(actual)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'actual' is not defined
>>> print(actual in expect)
wence- commented 4 years ago

OK, this:

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

is the issue.

For reasons that escape me, Apple's version of Python 3 doesn't ship with SSL certificates. This stackoverflow post has some suggestions.

What we usually suggest is to install homebrew python (brew install python) and then use /usr/local/bin/python. You can confirm that this solves the problem by first running the script I provided before trying firedrake-install again.

elma16 commented 4 years ago

Ok, so I tried /usr/local/bin/python (after brew install python) before running the script you provided, and it gave me the following;


The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ElliottsMacBook:~ elliottmacneil$ /usr/local/bin/python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import urllib.request
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named request
>>> tarball = "eigen-3.3.3.tgz"
>>> url = "https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz"
>>> sha = hashlib.sha256()
>>> expect = ("df6082711532336354466bab70f66c16ff88e616ac3884eba555b6f0b4860e65",
...           "94878cbfa27b0d0fbc64c00d4aafa137f678d5315ae62ba4aecddbd4269ae75f")
>>> urllib.request.urlretrieve(url, filename=tarball)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>> with open(tarball, "rb") as f:
...     while True:
...         data = f.read(65536)
...         if not data:
...             break
...         sha.update(data)
... actual = sha.hexdigest()
  File "<stdin>", line 7
    actual = sha.hexdigest()
         ^
SyntaxError: invalid syntax
>>> print(actual)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'actual' is not defined
>>> print(actual in expect)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'actual' is not defined

Moreover, if I try /usr/local/bin/python3 it gives me the following;


The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ElliottsMacBook:~ elliottmacneil$ /usr/local/bin/python3
Python 3.8.3 (default, Jul  8 2020, 14:27:55) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import urllib.request
>>> tarball = "eigen-3.3.3.tgz"
>>> url = "https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz"
>>> sha = hashlib.sha256()
>>> expect = ("df6082711532336354466bab70f66c16ff88e616ac3884eba555b6f0b4860e65",
...           "94878cbfa27b0d0fbc64c00d4aafa137f678d5315ae62ba4aecddbd4269ae75f")
>>> urllib.request.urlretrieve(url, filename=tarball)
('eigen-3.3.3.tgz', <http.client.HTTPMessage object at 0x10f125eb0>)
>>> with open(tarball, "rb") as f:
...     while True:
...         data = f.read(65536)
...         if not data:
...             break
...         sha.update(data)
... actual = sha.hexdigest()
  File "<stdin>", line 7
    actual = sha.hexdigest()
    ^
SyntaxError: invalid syntax
>>> print(actual)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'actual' is not defined
>>> print(actual in expect)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'actual' is not defined
>>> 

So it seems like the issue has changed. Is there anything else we could try to fix this?

wence- commented 4 years ago

Can you save those lines to a file and try running ~python~ /usr/local/bin/python3 on the file (I think that pasting one by one in the interpreter likely doesn't get the indentation right).

elma16 commented 4 years ago

Right, I saved it to a file and inputting usr/local/bin/python3 script.py gave me the following:

df6082711532336354466bab70f66c16ff88e616ac3884eba555b6f0b4860e65
True

This seems to be working. However, when I try /usr/local/bin/python3 firedrake-install it fails. Attached is the install log.

firedrake-install.log

dham commented 4 years ago

The PETSc configure has failed. Please provide /Users/elliottmacneil/Desktop/firedrake/src/petsc/configure.log

elma16 commented 4 years ago

Attached is the configure.log file. configure.log

dham commented 4 years ago

The proximate cause of your problem is that configure is finding the archiver ("ar") at /opt/local/bin/ar but this archiver appears not to work. /opt is a surprising location to find ar, and more generally I note that your PATH variable contains a very large number of directories. It appears to be the case that you have several compiler toolchains installed or partially installed and configure is picking up a confused mixture of them. I also note that the brew doctor which happens at the start of the install script is picking up quite lot of externally installed files in directories that home-brew uses. Basically, you appear to have a lot of debris lying around from previously installed tools and this means you configure can't create a working environment. I suggest that you need to clean up your machine.

elma16 commented 4 years ago

I backed up my machine, before completely wiping the hard drive and reinstalling Mac OS Catalina. After installing homebrew python, the installation of Firedrake was successful. Thanks for the help!

sv2518 commented 4 years ago

I had to reinstall firedrake, because I screwed up petsc. I have the same issue as above now, but don't like the idea of whining my whole machine. Is there an alternative?

Brew doctor gives me

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae were deleted!
You should find replacements for the following formulae:
  python@2

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Library/Frameworks/Python.framework/Versions/3.8/bin/python3-config
  /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8-config

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python@2
  ghostscript
  open-mpi
wence- commented 4 years ago

I had to reinstall firedrake, because I screwed up petsc. I have the same issue as above now, but don't like the idea of whining my whole machine. Is there an alternative?

I presume the issue is not being able to get the eigen tarball using urlretrieve?

I think this is because you're using macos-provided python3.8?

Or is it the linker error?

sv2518 commented 4 years ago

It's the eigen tarball using urlretrieve issue. The last output before failure is

Downloading Eigen from 'https://github.com/eigenteam/eigen-git-mirror/archive/3.3.3.tar.gz' to 'eigen-3.3.3.tgz'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1317, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "firedrake-install", line 1395, in <module>
    install("petsc/")
  File "firedrake-install", line 734, in install
    build_and_install_petsc()
  File "firedrake-install", line 819, in build_and_install_petsc
    urllib.request.urlretrieve(url, filename=tarball)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1360, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>

The install log is here firedrake-install.log

I tried to get the right python with brew update python@3.8 and then run python3.8 firedrake-install, but I still have the same issue.

wence- commented 4 years ago

What does which python3.8 say? I see firedrake-install was run with /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8. And your PATH looks like PATH=...:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin

So you're picking up the MacOS provided python. You can either expunge that directory from your PATH, or else install the certificates (I think /Library/Frameworks/Python.framework/Versions/3.8/bin/pip install certifi might work?) You can confirm that things will work by running the test from https://github.com/firedrakeproject/firedrake/issues/1769#issuecomment-653431423

sv2518 commented 4 years ago

Ah this is annoying, you are right. After expunging the macOS python from the PATH which python3.8 gives /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8. which python3 gives /Users/sv2518/frd/firedrake/bin/python3, but python3 firedrake-install gives

dyld: Library not loaded: /usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /Users/sv2518/frd/firedrake/bin/python3
  Reason: image not found
sv2518 commented 4 years ago

And python3.8 firedrake-install says

Traceback (most recent call last):
  File "firedrake-install", line 1395, in <module>
    install("petsc/")
  File "firedrake-install", line 734, in install
    build_and_install_petsc()
  File "firedrake-install", line 840, in build_and_install_petsc
    check_call(["python3", "./configure", "PETSC_DIR={}".format(petsc_dir), "PETSC_ARCH={}".format(petsc_arch)] + list(petsc_options))
  File "firedrake-install", line 534, in check_call
    log.debug(subprocess.check_output(arguments, stderr=subprocess.STDOUT, env=os.environ).decode())
  File "/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['python3', './configure', 'PETSC_DIR=/Users/sv2518/firedrakeinstalls/firedrake/src/petsc', 'PETSC_ARCH=default', '--download-suitesparse', '--with-debugging=0', '--download-hdf5=https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.6/src/hdf5-1.10.6.tar.bz2', '--download-netcdf', '--with-cxx-dialect=C++11', '--download-pastix', '--download-pnetcdf', '--with-fortran-bindings=0', '--download-ptscotch', '--download-hypre', '--download-eigen=/Users/sv2518/firedrakeinstalls/firedrake/src/eigen-3.3.3.tgz ', '--download-metis', '--download-chaco', '--download-ml', '--download-mpich', '--download-superlu_dist', '--download-mumps', '--download-scalapack', '--with-zlib', '--with-c2html=0', '--download-hwloc', '--with-shared-libraries=1']' died with <Signals.SIGABRT: 6>.
wence- commented 4 years ago

which python3 gives /Users/sv2518/frd/firedrake/bin/python3

You needed to deactivate the venv so that you get /usr/local/bin/python3 I think

sv2518 commented 4 years ago

Okay, now which python3 says /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 [Edit: it says /usr/local/bin/python3 now]

sv2518 commented 4 years ago

Ah, looks like it is installing now! Thanks!