Error installing new Python packages on Windows 7

Posted by in Python

In a previous post I write aboput how easy to install new Python modules and packages under Windows, but some times, on Windows, this task may be not as simple and easy as you can imagine (last post was writen using Windows XP but this one).

As we did before, let’s install NumPy on Windows 7, using “pip” and “easy_install“, but I got errors with both.

Error con pip

Error with pip

Error con Easy_install

Error with Easy_install

As you can imagine, things are not going the way it should, and i need to investigate how to solve the  vcvarsall.bat error. I read here about it, and it seems like Python is needing a compiler, not installed in my machina, and the error reaised!

Solution 1

Once I knew the problem, the easiest way to solve it is to delve inside this Python package repository for Windows, and download what you need, beause it’s ready to install (instead of doing it with “pip” or “easy_install“). As you can see, the website includes the most popular packages, and in my opinion, it’s the recommended solution, avoiding a lot of problems!

Solution 2

There is another alternative solution: to compile yourself the library using GCC as described here. I didn’t try, but I leave you the page, if you want to try!

La third solution (inviable on Windows 7)

I got a third solution to solve the error here: http://ultrainfinitum.blogspot.com.es/2012/12/python-error-unable-to-find-vcvarsallbat.html. You need to install MinGW, (in my case, c:\mingw) and keep on doing the following steps:

  • Start / Search “edit system variables” , and find the PATH variable under “Environment Variables“, to include c:\mingw\bin
PATH para MinGW

PATH fo MinGW

  • Next, go to c:\python27\lib\disutils path and create a file named (in case it doesn’t exist) distutils.cfg with the content:

[build]

compiler=mingw32

  • and finally, you should add the next command for compiling the library
    setup.py install build --compiler=mingw32

I tried this way, but I end up that it was  imposible to finish it. On the second answer at stackoverflow, the best solution is our first solutions. But there is still a hope for cientific topics: http://spyder-ide.blogspot.de/2012/08/scientific-python-distribution-for.html.

To end with …

I must admit the first option is the one I am using, every time it should be. You should be aware of dependencies!

Of course, you can try pip and easy_install and in case you got an error, use this option!