r/Python • u/JewishIGuess • Jun 08 '15
Installing Numpy is not working
I have 64-bit windows, python 3.4, and I need to install numpy. I've downloaded it from multiple sources, and followed multiple sets of instructions. But anything I do in the command prompt throws an error, either from pip for from the file location where numpy is.
Could somebody walk me through, step by step by step, what to do to install numpy? It would be greatly appreciated.
3
u/captaink Jun 08 '15
I had the same problems trying to install numPy and SciPy.
Ended up using the winPython distribution, works flawlessly
2
u/Mashidin Jun 08 '15
I do quite a bit of python dev on my windows machine and have run in to this issue before. My solution is that I have MINGW installed. It has bunch of fun UNIX tools included, one of which is gcc the gnu C compiler. The problem you have, I believe is that python cannot find the compiler you wish to use to build all the C binaries. I fought a bit with the solution where I deal with the compiler included with VS 2008 and that turn out to be smarter than me. So once you install and understand MINGW (which is super simple) you configure distutils to point to MINGW. This check list that I stole explains it pretty well: 1.I have Python already installed 2. I installed mingw32 to C:\programs\mingw
3.Add mingw32's bin directory to your environment variable: append c:\programs\MinGW\bin; to the PATH 4.(create if not existing) distutils.cfg file located at C:\PythonXX\Lib\distutils\distutils.cfg to be:
[build] compiler=mingw32
Your mileage my vary.
2
2
u/LeftyDave Jun 08 '15
1
u/Zifendale Jun 09 '15
This is the correct answer, it is essentially what I did in my script but it is easier to follow!
1
u/Zifendale Jun 08 '15
I had the same problem (with python 3.3) and had to solve it... twice. So the second time around I made a batch script with the steps I took. This script also sets it up in a virtualenv so you will need to adjust it for your needs. The prerequisites may have some overlap as well...
I sometimes used easy_install for easy to get windows binaries, keep an eye out for those requirements.
Again, you will need to adjust this script for your needs...
Here is the script!
REM Prerequisites:
REM git http://git-scm.com/
REM Visual C++ 2010 Express (For Python 3.0+) https://app.vssps.visualstudio.com/profile/review?download=true&family=VisualStudioCExpress&release=VisualStudio2010&type=web&slcid=0x409&context=eyJwZSI6MSwicGMiOjEsImljIjoxLCJhbyI6MCwiYW0iOjAsIm9wIjpudWxsLCJhZCI6MSwiZmEiOjAsImF1IjpudWxsLCJjdiI6MjEyMTY5MzIyMSwiZnMiOjAsInN1IjowLCJlciI6MX01
REM Windows SDK for Win7 and .NET Framework 4 https://www.microsoft.com/en-us/download/details.aspx?id=8442
REM Windows Compiler SP1 Patch http://www.microsoft.com/en-us/download/details.aspx?id=4422
REM Fortran Compiler g77 provided via Windows Binary from MinGW http://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download
REM Add C:\MinGW\bin to Environment Variables
REM Create virtualenv
@echo off
SET virtenvdir="C:\VIRTUALENV FOLDER LOCATION"
SET scriptdir="C:\VIRTUALENV FOLDER LOCATION\Scripts"
SET repodir="C:\VIRTUALENV FOLDER LOCATION\Repos"
SET sdkdir="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin"
cd %sdkdir%
SET DISTUTILS_USE_SDK=1
call setenv /x64 /release
cd %virtenvdir%
echo Activating virtualenv
call .\Scripts\activate.bat
echo Installing dependencies
cd %scriptdir%
REM Cython is a required as C compiler dependency for Numpy and Pandas
call easy_install.exe "%virtenvdir%%\Prereqs\pyodbc-3.0.7.win-amd64-py3.3.exe"
REM Rpy2 dependencies
call pip3.3.exe install wheel
call pip3.3.exe install "%virtenvdir%%\Prereqs\rpy2-2.5.6-cp33-none-win_amd64.whl"
call easy_install.exe "%virtenvdir%%\Prereqs\pywin32-219.win-amd64-py3.3.exe"
call pip3.3.exe install singledispatch
call pip3.3.exe install -U Cython
call pip3.3.exe install -U SQLAlchemy
echo Pulling required repositories
cd %repodir%
REM clone repos from github
call git clone https://github.com/numpy/numpy.git
REM call git clone https://github.com/scipy/scipy.git
REM call git clone https://github.com/ipython/ipython.git
call git clone https://github.com/pydata/pandas.git
REM Compile each repo and install under current virtualenv
echo Compiling repositories
cd "%repodir%\numpy"
call python setup.py build
call python setup.py install
REM cd "%repodir%\scipy"
REM call git clean -xdf
REM call python setup.py install
REM cd "%repodir%\ipython"
REM call python setupegg.py install
REM cd "%repodir%\pandas"
call python setup.py build_ext --inplace
call python setup.py install
echo Deactivating virtualenv
cd %virtenvdir%
call .\Scripts\deactivate.bat 1
1
u/jackmaney Jun 08 '15
Yeah, Python development in Windows is a major pain in the ass. Some things (including installation of NumPy via pip) that Just Work in *nix or OS X will either fail miserably or require annoying workarounds for Windows.
If you can, try to get an Ubuntu VM set up on VirtualBox.
7
u/joshadel Jun 08 '15
I would consider grabbing the whl file from Christoph Gohlke's website: http://www.lfd.uci.edu/~gohlke/pythonlibs/
pip can directly install whl files: pip install <whl_file>
or check out the free conda/anaconda if you need more of the scientific stack and a nice way of isolating different environments:
https://store.continuum.io/cshop/anaconda/
http://conda.pydata.org/miniconda.html