0

I'm trying to install SciPy on a Ubuntu machine in the cloud. Here are the steps I followed:

  • sudo pip install numpy
  • sudo apt-get install gfortran
  • sudo apt-get install libblas-dev
  • sudo apt-get install liblapack-dev
  • sudo apt-get install g++
  • sudo pip install scipy

For your information, it's Ubuntu 14.04, Python 2.7.6. I did not install Python, it was already in the machine, just like pip and easy_install. Here is the pip.log:

(.text+0x20): undefined reference to `main'

collect2: error: ld returned 1 exit status

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':

(.text+0x20): undefined reference to `main'

collect2: error: ld returned 1 exit status

error: Command "/usr/bin/gfortran -Wall -g -L/opt/bitnami/common/lib -L/opt/bitnami/common/lib build/temp.linux-x86_64-2.7/numpy/core/blasdot/_dotblas.o -L/usr/lib
-L/opt/bitnami/python/lib -Lbuild/temp.linux-x86_64-2.7 -lopenblas -lpython2.7 -lgfortran -o build/lib.linux-x86_64-2.7/numpy/core/_dotblas.so" failed with exit status 1

----------------------------------------  
Cleaning up...   Removing temporary dir /tmp/pip_build_root... Command /opt/bitnami/python/bin/.python2.7.bin -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Lm8nxq-record/install-record.txt
    --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/numpy Exception information: 

Traceback (most recent call last):
File "/opt/bitnami/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 130, in main
    status = self.run(options, args)   File "/opt/bitnami/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)   File "/opt/bitnami/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)   File "/opt/bitnami/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)   File "/opt/bitnami/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd)) InstallationError: Command /opt/bitnami/python/bin/.python2.7.bin -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Lm8nxq-record/install-record.txt
--single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/numpy

pip file:

#!/opt/bitnami/python/bin/.python2.7.bin
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.5.6','console_scripts','pip'
__requires__ = 'pip==1.5.6' import sys from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
    )

easy_install file:

#!/usr/bin/env /opt/bitnami/python/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'distribute==0.6.34','console_scripts','easy_install'
__requires__ = 'distribute==0.6.34' import sys from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('distribute==0.6.34', 'console_scripts', 'easy_install')()
    )

Please help.

Is this caused by the gfortran compiler flags? Just a suspicion.

dda
  • 6,030
  • 2
  • 25
  • 34
Rachid O
  • 13,013
  • 15
  • 66
  • 92

3 Answers3

5

Ubuntu packages

The SciPy manual suggests the Ubuntu version instead of the pip version:

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

pip

Another approach would be installing the prerequisites:

sudo apt-get install python-pip python-dev build-essential
sudo pip install numpy
sudo apt-get install libatlas-base-dev gfortran
sudo pip install scipy

I've just tested it on an AWS Ubuntu 14.04 machine, and everything seems to work, after a very long compilation process with tons of warnings.

I generally recommend using the later, because it works on any virtualenv, while the former installs the packages system-wide.

Community
  • 1
  • 1
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
  • i did install them via apt-get but then python acts liks they are not installed: no module named scipy – Rachid O Nov 01 '14 at 13:18
  • They were probably installed on a different Python interpreter. Try the pip way, which will also work in a virtualenv. – Adam Matan Nov 01 '14 at 13:19
  • i did as you mentioned but the same error shows again :( , i'm not sure but i think it has something to do with the gfortran compiler flags – Rachid O Nov 01 '14 at 13:36
2

I was able to install numpy / scipy on bitnami by changing this environment variable:

export LDFLAGS="-shared"

Then the steps to install to scipy are:

sudo apt-get update -y
sudo apt-get install python-pip python-dev build-essential
sudo pip install numpy
sudo apt-get install libatlas-base-dev gfortran
sudo pip install scipy

reference numpy issue

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
jonincanada
  • 417
  • 5
  • 5
0

this problem is still persisting so i remove the custom installation that was on /opt/bitnami/python and started using the system installation and now everything works fine

i installed scipy and numpy using

sudo apt-get install python-numpy python-scipy
Rachid O
  • 13,013
  • 15
  • 66
  • 92