Can't install SciPy on production server
Question: 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.


Answer: # Ubuntu packages

The SciPy manual [suggests the Ubuntu version instead of the pip
version](http://www.scipy.org/install.html#ubuntu-debian):

    
    
    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](http://stackoverflow.com/a/15355787/51197):

    
    
    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.

