Installing SciPy with pip - python

It is possible to install NumPy with pip using pip install numpy.
Is there a similar possibility with SciPy? (Doing pip install scipy does not work.)
Update
The package SciPy is now available to be installed with pip!

Prerequisite:
sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
sudo pip install --upgrade pip
Actual packages:
sudo pip install numpy
sudo pip install scipy
Optional packages:
sudo pip install matplotlib OR sudo apt-get install python-matplotlib
sudo pip install -U scikit-learn
sudo pip install pandas
src

An attempt to easy_install indicates a problem with their listing in the Python Package Index, which pip searches.
easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Reading http://www.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
Reading http://new.scipy.org/Wiki/Download
All is not lost, however; pip can install from Subversion (SVN), Git, Mercurial, and Bazaar repositories. SciPy uses SVN:
pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy
Update (12-2012):
pip install git+https://github.com/scipy/scipy.git
Since NumPy is a dependency, it should be installed as well.

In Ubuntu 10.04 (Lucid), I could successfully pip install scipy (within a virtualenv) after installing some of its dependencies, in particular:
$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev

To install scipy on windows follow these instructions:-
Step-1 : Press this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).
Step-2: Go to the directory where that download file is there from the command prompt (cd folder-name ).
Step-3: Run this command:
pip install scipy-0.17.0-cp27-none-win_amd64.whl

I tried all the above and nothing worked for me. This solved all my problems:
pip install -U numpy
pip install -U scipy
Note that the -U option to pip install requests that the package be upgraded. Without it, if the package is already installed pip will inform you of this and exit without doing anything.

If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using Arch Linux), I can get SciPy installed with:
pip install scipy

On Fedora, this works:
sudo yum install -y python-pip
sudo yum install -y lapack lapack-devel blas blas-devel
sudo yum install -y blas-static lapack-static
sudo pip install numpy
sudo pip install scipy
If you get any public key errors while downloading, add --nogpgcheck as parameter to yum, for example:
yum --nogpgcheck install blas-devel
On Fedora 23 onwards, use dnf instead of yum.

For the Arch Linux users:
pip install --user scipy prerequisites the following Arch packages to be installed:
gcc-fortran
blas
lapack

Addon for Ubuntu (Ubuntu 10.04 LTS (Lucid Lynx)):
The repository moved, but a
pip install -e git+http://github.com/scipy/scipy/#egg=scipy
failed for me... With the following steps, it finally worked out (as root in a virtual environment, where python3 is a link to Python 3.2.2):
install the Ubuntu dependencies (see elaichi), clone NumPy and SciPy:
git clone git://github.com/scipy/scipy.git scipy
git clone git://github.com/numpy/numpy.git numpy
Build NumPy (within the numpy folder):
python3 setup.py build --fcompiler=gnu95
Install SciPy (within the scipy folder):
python3 setup.py install

In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran
sudo apt-get install libatlas-base-dev gfortran
Then run pip install scipy

install python-3.4.4
scipy-0.15.1-win32-superpack-python3.4
apply the following commend doc
py -m pip install --upgrade pip
py -m pip install numpy
py -m pip install matplotlib
py -m pip install scipy
py -m pip install scikit-learn

The answer is yes, there is.
First you can easily install numpy use commands:
pip install numpy
Then you should install mkl, which is required by Scipy, and you can download it here
After download the file_name.whl you install it
C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl
Installing collected packages: mkl-service
Successfully installed mkl-service-1.1.2
Then at the same website you can download scipy-0.18.1-cp35-cp35m-win32.whl
Note:You should download the file_name.whl according to you python version, if you python version is 32bit python3.5 you should download this one, and the "win32" is about your python version, not your operating system version.
Then install file_name.whl like this:
C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
Then there is only one more thing to do: comment out a specfic line or there will be error messages when you imput command "import scipy".
So comment out this line
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
in this file: your_own_path\lib\site-packages\scipy__init__.py
Then you can use SciPy :)
Here tells you more about the last step.
Here is a similar anwser to a similar question.

Besides all of these answers,
If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
In the above URL you can download the packages and command is: pip install

For gentoo, it's in the main repository:
emerge --ask scipy

You can also use this in windows with python 3.6 python -m pip install scipy

Related

Problem with pip, cant install modules from cmd

I just get a syntax error. I've tried these commands:
pip install opencv-python
pip3 install opencv-python
python -m pip install opencv-python
All of these just give me a syntax error.
Trying to install opencv for some webcams, going to be messing with raspberry later.
If you are on Windows you have just to type py -m pip install opencv-python.
If you are on a Linux distribution you should firstly install python-pip or python3-pip (via your package manager) and then type:
pip (or pip3) install opencv-python (if you want to install it locally).
sudo pip (or pip3) install opencv-python (if you want to install it globally).
You can find more information here.

apt-get install python3-numpy doesn't install numpy on python3, but installed on python2.7

I'm trying to install numpy for python3, and I used sudo apt-get install python3-numpy to install numpy as I use Jetson tx2.
Although the installation is successful, but numpy is installed on python2.7 not python3. How can I solve it?
Actually when you flash your Jetson TX2 with Jetpack (version), numpy package is present for Python2 by default and not for Python3.
In order to install numpy for Python3 Please follow the steps given below:-
1. Check if you have pip3 installed for Python3. If not install pip3.
sudo apt install python3-pip
2. Then using pip3 install numpy
pip3 install numpy
After installation check the location: /usr/local/lib/python3.6/dist-packages you will find numpy installed for Python3 Hope this helps!
I think this is because your default interpreter is Py v2.7
Check this by runnin in console:
python -V
Then you can specify Py3 installation as was commented above:
pip3 install numpy
Note: Do not run this command with sudo because it will run setup.py
with sudo or
in other words - an arbitraty upload a malicious project on PyPI this
is a hight risk action.
You can try using the python3 package manager :
pip3 install --user numpy

Install scipy for both python 2 and python 3

I used sudo apt-get install python-scipy to install scipy. This put all the files in /usr/lib/python2.7.dist-packages/scipy. My best guess is it chose that location because python 2.7 was the default version of python. I also want to use scipy with python 3 however. Does the package need to be rebuilt for python 3 or can I just point python 3 to the existing version?
I've tried using pip to install two parallel version, but I can't get the dependency libblas3 installed for my system.
What's the best way to do this?
I'm on Debian Jessie.
To install scipy for python3.x the on a debian-based distribution:
sudo apt-get install python3-scipy
This corresponds to the python2.x equivalent:
sudo apt-get install python-scipy
On a more platform-independent note, pip is the more standard way of installing python packages:
pip install --user scipy #pip install using default python version
To make sure you are using the right pip version you can always be more explicit:
pip2 install --user scipy # install using python2
pip3 install --user scipy # install using python3
Also, I believe anaconda or the more lightweight miniconda were intended to make installation of python packages with complex dependencies more easy, plus it allows for using an environment, making it easier to have several configurations with non-compatible versions etc. This would create+use a python binary different from the one on your system though.
One would then install scipy using the command conda:
conda install scipy
If installing scipy for a specific version you would create an environment with that python version:
conda create -n my_environment_name python=3 scipy
One could also use pip inside a conda environment alongside conda python packages, but I would make sure that you are using pip installed using conda to avoid conflicts. An added benefit when installing conda for a user, is that you don't have to add the --user flag when installing with pip.
If you can't find python3-scipy using apt-get you can use pip to install it for python3, you just have to make sure you use pip3 (if you don't have it apt install python3-pip
pip3 install --user scipy
You may want to try with pip3 install scipy

Install numpy in Python virtualenv

I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have the error when installing numpy in the virtualenv.
Maybe, you have any ideas to fix?
The problem is SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
sudo apt-get update
sudo apt-get upgrade gcc
then install the python2.7-dev
sudo apt-get install python2.7-dev
and I see that you have most probably already done the above things.
pip will eventually spit out another error for not being able to write into /user/bin/blahBlah/dist-packages/ or something like that because it couldn't figure out that it was supposed to install your desiredPackage (e.g. numpy) within the active env (the env created by virtualenv which you might have even changed directory to while doing all this)
so do this:
pip -E /some/path/env install desiredPackage
that should get the job done... hopefully :)
---Edit---
From PIP Version 1.1 onward, the command pip -E doesn't work. The following is an excerpt from the release notes of version 1.1 (https://pip.pypa.io/en/latest/news.html)
Removed -E/--environment option and PIP_RESPECT_VIRTUALENV; both use a restart-in-venv mechanism that's broken, and neither one is useful since every virtualenv now has pip inside it. Replace pip -E path/to/venv install Foo with virtualenv path/to/venv && path/to/venv/pip install Foo
If you're on Python3 you'll need to do sudo apt-get install python3-dev. Took me a little while to figure it out.
If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
"numpy installation thru install_requires directive issue..."
Work around is to manually install numpy in your (virtual) environment before running setup.py to install whatever you want to install that depends on numpy.
eg, pip install numpy then python ./setup.py install
This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
I recently had the same problem. I run Debian Jessie and tried to install numpy from a Python 2.7.9 virtualenv. I got the same error -- numpy complaining that Python.h is missing while python2.7-dev and gcc are already installed.
File "numpy/core/setup.py", line 42, in check_types
],
File "numpy/core/setup.py", line 293, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
I'm running pip 1.5.6 and it doesn't appear to have command line option '-E'
$ pip -V
pip 1.5.6 from /home/alex/.virtualenvs/myenv/local/lib/python2.7/site- packages (python 2.7)
Upgrading pip to the latest verson 7.0.3 solves the problem
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Now it is possible to install numpy
$ pip install numpy
Collecting numpy
Downloading numpy-1.9.2.tar.gz (4.0MB)
100% |████████████████████████████████| 4.0MB 61kB/s
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy-1.9.2
This is probably because you do not have the python-dev package installed. You can install it like this:
sudo apt-get install python-dev
You can also install it via the Software Center:
#samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy.

Why does installing numpy require python-dev in Kubuntu 12.04

Just starting out in python on a pendrive 12.04 Kubuntu environment. I had to install GCC (understand that), but I also had to install python-dev before I could use PIP to install numpy. Why do I need python-dev?
sudo apt-get install gcc
sudo apt-get install pip
cd /usr/lib/python2.7/
sudo apt-get install python-dev
sudo pip install numpy
When you use pip to install numpy, the packages is compiled from source. The pythonx.x-dev packages contain the necessary header files for linking against python.

Categories

Resources