Python package requires newer version of libgfortran

Symptom:

When trying to import a python package that relies on fortran code, an error may occur if a version of libgfortran newer than that provided by Canopy/EDM is required.

For example, the python package https://pypi.python.org/pypi/camb/ specifically requires a version of the gfortran compiler greater or equal to 4.9. After installation, attempting to import this package in Canopy or an EDM shell session may result in an error similar to:  

/home/username/.local/share/canopy/edm/envs/User/bin/../lib/libgfortran.so.3: version `GFORTRAN_1.3' not found (required by /home/username/Desktop/CAMB-Jan/pycamb/camb/camblib.so)

 

Cause:

The cause of this problem is that a python package being used requires a newer version of the libgfortran.so file than that which is provided by the Cannopy/EDM installation.

 

Solution:

The workaround for this issue is to locate the version of libgfortran installed with your system's gfortran compiler, backup/rename the current libgfortran symlink that Canopy/EDM uses, then create a new symlink to the system libgfortran library.

Before continuing, please ensure that you have gfortran installed. This can be checked by executing the following from the command line:

gfortran --version

If you do not have gfortran installed, then please use your system package manager to install this compiler. For example on Ubuntu, gfortran can be installed by executing the following

sudo apt install gfortran

After ensuring you have gfortran installed, follow the steps below: 

First you'll need to locate the system libgfortran library. Ubuntu users should search in /usr/lib/x86_64-linux-gnu/ for the file libgfortran.so.3. Other versions of linux may have installed this file elsewhere. See the end of this article for possible locations to check. The libgfortran.so.3 file should be symlinked to a file called libgfortran.so.3.x.y. 

Second you'll need to locate the directory that Canopy checks for the libgfortran library when it is needed. This will be a location similar to ${HOME}/.local/share/canopy/edm/envs/User/lib. 

Third, you'll want to create a backup of the current libgfortran symlink in this directoy:

cd ${HOME}/.local/share/canopy/edm/envs/User/lib && mv ./libgfortran.so.3 ./libgfortran.so.3.back

Finally, you'll need to create a new symlink in this directory that links to your system libgfortran:

ln -s /path/to/your/system/libgfortran.so.3 ./libgfortran.so.3 

 

You should now be able to import the library correctly vis Canopy or a Canopy terminal session

 

Possible locations of libgfortran.so.3:

  • Ubuntu - check /usr/lib/x86_64-linux-gnu/
  • OpenSUSE and CentOS/RHEL - check /lib or /lib64 or /usr/lib or /usr/lib64
  • Other Linux variants - may need some trial and error to locate libgfortran.so.3, however its worth checking in the paths listed above.

 

 

Have more questions? Submit a request

Comments

Powered by Zendesk