Testing Scipy; get "No module named msvccompiler in numpy.distutils; trying from distutils" - python-2.7

I'm trying to test my scipy install by installing nose and entering
import scipy
scipy.test('1','10')
I get some 200 errors but one of the more common is:
.... No module named msvccompiler in numpy.distutils; trying from distutils
Missing compiler_cxx fix for MSVCCompiler
I have MS Virtual Studio 2009 installed (required for python 2.7)
Can anyone help me eliminate that error or tell my why I can't?
Thanks

You have to do 2 things to make it find the Visual Studio Compiler:
In your environment, set VS90COMNTOOLS=%VS__vvv__COMNTOOLS% where vvv is your installed version. See other related questions on stackoverflow about setup.py and vcvarsall.bat
Run python from a Visual Studio Developer Command Prompt. VS includes a link for this in the start menu. It sets up all the environment variables you need to run the compilers and related tools from the command line.

Best solution to this could be using the Anaconda Python distribution
It has most of the engineering and data analysis packages and automatically sets path of the C++ compiler. You can easily install numpy, scipy, matplotlib etc. using Anaconda. It will not show vcvarshall.bat as well as numpy.core.multiarray error for numpy

Related

Python 2.7 Opencv error, ImportError: DLL load failed: The specified module could not be found

Working on python 2.7(not anaconda). Operating system Windows server 2012 R2
The pypi installation mentions two fixes for this, installing Visual C++ redistributable 2015 and Universal C Runtime.
As well as a manual fix for older anaconda versions, which is for python3(I am not using anaconda version, and also my python version is 2.7 so presuming it doesn't apply in my case)
link here:
https://pypi.org/project/opencv-python/
installed both the dependencies but couldn't get it to work.
Any ideas on how I may fix this?
Since Python 2.7 is still supported, this could be the possible solution.
Installing OpenCV from prebuilt binaries:
Below Python packages are to be downloaded and installed to their default locations.
Python-2.7.x
Numpy
Matplotlib
Install all packages into their default locations. Python will be installed to C:/Python27/.
After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
Download latest OpenCV release and install it : Latest OpenCV-build
Goto opencv/build/python/2.7 folder.
Copy cv2.pyd to C:/Python27/lib/site-packeges.
Open Python IDLE and type following codes in Python terminal.
import cv2
print cv2.__version__

Running into an error when trying to implement Keras

I'm using Python 2.7, Windows 7, and Keras 1.2.1 (Keras2 seems to be having a lot of compatibility issues with different PC/Python configs, so I was recommened to use 1.2.1)
I'm using a script from Practical Deep Learning For Coders, Part 1 Course
import utils; reload(utils)
from utils import plots
The error I"m getting is as below
Problem occurred during compilation with the command line below:
"g++" -shared -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"c:\python27\lib\site-packages\numpy\core\include" -I"c:\python27\include" -I"c:\python27\lib\site-packages\theano\gof" -L"c:\python27\libs" -L"c:\python27" -o C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-2.7.12-64\lazylinker_ext\lazylinker_ext.pyd C:\Users\Moondra\AppData\Local\Theano\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_94_Stepping_3_GenuineIntel-2.7.12-64\lazylinker_ext\mod.cpp -lpython27
I can't decipher what this means. Google search brought up a Chinese message board.
It seems to be a g++ problem as the previous warning I got was as follows:
WARNING (theano.configdefaults): g++ not available, if using conda:conda install m2w64-toolchain``. Despite installing m2w64-toolchain afterwards, I was continuing to get the same warning.
Some interesting things I learned while trying to configure theano and keras:
C++/g++
Depending on your python version, you have to install a corresponding version of the C++ compiler, or Visual Studio. Ex: Python 2.7 needs C++ 9.0 (Visual Studio 2008). But Python 3.5 needs C++ 14.0 (Visual Studio 2015) -- See here for more: https://wiki.python.org/moin/WindowsCompilers
I also had to install MinGW for g++ compilers: https://nuwen.net/mingw.html
Even with it correctly installed, you may see an error about hypot. This question shows two possible solutions: g++ error on import of Theano on Windows 7
I tried installing everything via Conda, but all calculations were slower than continents moving away from each other. Then I gave up conda and installed everything via standard python. (First python, then numpy, then scipy, then theano, then keras). Not sure if MinGW goes before of after numpy/scipy, but I think it goes before.
BLAS/LAPACK
Numpy and theano may warn you that no lapack/blas is installed. For that, I used the numpy and scipy libraries available here, they're great and fast: http://www.lfd.uci.edu/~gohlke/pythonlibs/
Another option is installing MKL directly from Intel, before installing numpy and scipy.
Path problems / Invalid Token - ldflags
Avoid installing anything, including the MKL, in folders containing spaces in their names! That will definitely confuse theano/numpy.
You may get "invalid token" errors if you have spaces in folders, and a ldflags var described in that error. To solve that, either reinstall your mkl libraries in folders without spaces, or configure the .theanorc file in the theano home folder with your [blas] configuration and the ldflags var. (See here: Receive AssertionError while optimizing convolution in theano)
Since I wasn't willing to reinstall MKL in another folder, I learned to create symbolic links to windows. (in the answer above)
Replace the folders with space in the theano config and also in the numpy config files (__config__.py), you can see its content with np.__config__.show(). (See answer above)
I solved the problem.
I reinstalled Anaconda.
And then via command line I wrote conda install m2w64-toolchain
This time I didn't get a message stating that m2w64 was already installed. I'm assuming it was a path issue and this time reinstalling everything from the start also created a new path?

Error "from scipy.linalg import _fblas importerror: DLL load failed"

I found a code on internet which implement a paper "Effective 3D Action
Recognition Using EigenJoints" code. They implement in Python so I tried to install Python 2.7.9 and numpy, scipy, scikit-learn. All these libraries installed successfully. In the cmd when i tried to run python eigen.py it gives me this error.
Please anyone download this code and run it by yourself or help me to solve this error.
You have to do 2 steps:
download anaconda according to your system and specifications.
Make sure that Anaconda is installed on python version installed on your system. For example, if you have python 3.4, and anaconda in installled on 2.7, then you should remove python 3.4.
Afterwards, the code will run smoothly and all libraries will be well defined. I have made the same ;) Please, let me know if you face new problems.

pyproj with Python 2.7.9 on win7 64 gives "Unable to find vcvarsall.bat"

I need to install pyproj on my machine and it give the above mentioned error. I guess it would be the same for other python components that are using C++ code:
My situation:
Win 7 64 bit running.
installed:
VS 2008 express
MS VS patch for python 2.7 http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505
Python Setup Tools available here: http://pypi.python.org/pypi/setuptools#downloads
set up the path variables and set
VS90COMNTOOLS
Value: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools
I try to install the pyproj: http://jswhit.github.io/pyproj/
but it returns the same error:
File "msvc9compiler.py", line 271, in query_vcvarsall raise DistutilsPlatformError("Unable to find vcvarsall.bat") distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
the purpose of this is to get the pygrib package running: http://jswhit.github.io/pygrib/docs/index.html
Does anybody know how to solve the problem?
You can install this without needing to compile it by using a precompiled Python wheel. You can find a compatible wheel for pyproj at this page containing unofficial wheels.
You are specifically looking for pyproj-1.9.4-cp27-none-win_amd64.whl. Once you download the whl file, you can install it with pip using
pip install pyproj-1.9.4-cp27-none-win_amd64.whl
And that will install it for you, skipping the compilation process.

Install Numpy compiled for VS2010 for an embedded interpreter

Another of my queries about an embedded Python 2.7.3 interpreter on Windows. I need to install numpy and matplotlib as support packages for an embedded interpreter in a C++ program compiled in Visual Studio 2010.
Some background:
I've been trying to make this work for a few months. The main issue is that numpy for Python 2.7 is compiled against an earlier version of the MS C library (VS2008) whereas my application is compiled against the 2010 version (a fact beyond my control - that is the office compiler).
I worked around this by fiddling with the manifest for my application to let it load the correct C library for numpy and this got it to import. As an end-user has tried out new features, bugs have started to appear, including untraceable crashes.
My current state:
I pinned some of these down to a poor compilation on my part of the Python 2.7.3 source, in particular the dependencies (lots of the crashes seemed associated with Tkinter from matplotlib). So I started afresh on the Python compilation and now have a clean compiled version of all the core and dependencies of Python 2.7.3. Now I'm looking at numpy/matplotlib.
My questions
Is it worth attempting to compile numpy against VS2010 or is my earlier manifest mangling solution the only way?
If the former, what problems might I encounter in doing so (i.e. what should I watch ou for)?
In the latter, how do I get numpy to install in the lib/site-packages folder of my embedded intepreter?
use cygwin to build numpy on windows.
I am on windows-xp
Its working fine for me.. .!
In cygwin python2.6 comes as a default python. I have installed python2.7 but not installed numpy in python2.7.
To use it on python2.7 i have run python2.7 setup.py build
You can see that in screen-shot of my terminal. and in folder 'namit' i have placed 'numpy' dir that i have compiled on cygwin.
when i have imported numpy when i am in that dir.. it worked...you can see that in globals() from where it has imported.